2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2004-10-01 14:10:30 +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.
|
2004-10-01 14:10:30 +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.
|
2004-10-01 14:10:30 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) Blender Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2004-10-01 14:10:30 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/softbody.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/*
|
|
|
|
******
|
|
|
|
variables on the UI for now
|
2005-04-02 13:57:23 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
float mediafrict; friction to env
|
|
|
|
float nodemass; softbody mass of *vertex*
|
|
|
|
float grav; softbody amount of gravitaion to apply
|
|
|
|
|
|
|
|
float goalspring; softbody goal springs
|
|
|
|
float goalfrict; softbody goal springs friction
|
|
|
|
float mingoal; quick limits for goal
|
2005-04-02 13:57:23 +00:00
|
|
|
float maxgoal;
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
float inspring; softbody inner springs
|
|
|
|
float infrict; softbody inner springs friction
|
2005-01-12 22:28:13 +00:00
|
|
|
|
|
|
|
*****
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
2005-01-13 13:58:29 +00:00
|
|
|
#include <string.h>
|
2004-10-01 14:10:30 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
/* types */
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_lattice_types.h"
|
2005-04-02 19:52:32 +00:00
|
|
|
#include "DNA_curve_types.h"
|
2004-10-01 14:10:30 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
2016-07-31 18:56:44 +10:00
|
|
|
#include "DNA_group_types.h"
|
2004-10-01 14:10:30 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-10-20 13:50:24 +00:00
|
|
|
#include "BLI_listbase.h"
|
2006-11-10 23:09:16 +00:00
|
|
|
#include "BLI_ghash.h"
|
2008-08-11 20:40:29 +00:00
|
|
|
#include "BLI_threads.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"
|
2005-11-17 11:40:57 +00:00
|
|
|
#include "BKE_curve.h"
|
2005-04-04 18:09:47 +00:00
|
|
|
#include "BKE_effect.h"
|
2004-10-01 14:10:30 +00:00
|
|
|
#include "BKE_global.h"
|
2018-06-08 19:26:46 +02:00
|
|
|
#include "BKE_layer.h"
|
2011-07-08 13:22:58 +00:00
|
|
|
#include "BKE_modifier.h"
|
2004-10-01 14:10:30 +00:00
|
|
|
#include "BKE_softbody.h"
|
2016-12-28 17:30:58 +01:00
|
|
|
#include "BKE_pointcache.h"
|
2009-06-24 23:42:45 +00:00
|
|
|
#include "BKE_deform.h"
|
2012-07-18 23:07:07 +00:00
|
|
|
#include "BKE_mesh.h"
|
2013-05-08 13:23:17 +00:00
|
|
|
#include "BKE_scene.h"
|
2012-07-18 23:07:07 +00:00
|
|
|
|
2017-07-21 11:53:13 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2018-04-06 12:07:27 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
2017-07-21 11:53:13 +02:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
#include "PIL_time.h"
|
2006-11-20 22:27:05 +00:00
|
|
|
|
|
|
|
/* callbacks for errors and interrupts and some goo */
|
|
|
|
static int (*SB_localInterruptCallBack)(void) = NULL;
|
|
|
|
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
/* ********** soft body engine ******* */
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
typedef enum {SB_EDGE=1, SB_BEND=2, SB_STIFFQUAD=3, SB_HANDLE=4} type_spring;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
typedef struct BodySpring {
|
|
|
|
int v1, v2;
|
2012-04-29 15:47:02 +00:00
|
|
|
float len, cf, load;
|
2006-10-14 19:03:06 +00:00
|
|
|
float ext_force[3]; /* edges colliding and sailing */
|
2009-11-04 00:21:25 +00:00
|
|
|
type_spring springtype;
|
2006-10-10 21:49:02 +00:00
|
|
|
short flag;
|
2005-08-15 10:30:53 +00:00
|
|
|
} BodySpring;
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
typedef struct BodyFace {
|
2015-07-31 19:01:51 +10:00
|
|
|
int v1, v2, v3;
|
2008-01-31 23:00:08 +00:00
|
|
|
float ext_force[3]; /* faces colliding */
|
2006-11-10 23:09:16 +00:00
|
|
|
short flag;
|
|
|
|
} BodyFace;
|
|
|
|
|
2009-11-21 22:45:25 +00:00
|
|
|
typedef struct ReferenceVert {
|
|
|
|
float pos[3]; /* position relative to com */
|
|
|
|
float mass; /* node mass */
|
|
|
|
} ReferenceVert;
|
|
|
|
|
|
|
|
typedef struct ReferenceState {
|
|
|
|
float com[3]; /* center of mass*/
|
|
|
|
ReferenceVert *ivert; /* list of intial values */
|
2012-04-21 13:37:26 +00:00
|
|
|
} ReferenceState;
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
/*private scratch pad for caching and other data only needed when alive*/
|
|
|
|
typedef struct SBScratch {
|
|
|
|
GHash *colliderhash;
|
|
|
|
short needstobuildcollider;
|
|
|
|
short flag;
|
|
|
|
BodyFace *bodyface;
|
|
|
|
int totface;
|
2012-04-29 15:47:02 +00:00
|
|
|
float aabbmin[3], aabbmax[3];
|
2009-11-21 22:45:25 +00:00
|
|
|
ReferenceState Ref;
|
2012-04-21 13:37:26 +00:00
|
|
|
} SBScratch;
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
typedef struct SB_thread_context {
|
|
|
|
Scene *scene;
|
2010-03-22 09:30:00 +00:00
|
|
|
Object *ob;
|
2008-08-11 20:40:29 +00:00
|
|
|
float forcetime;
|
|
|
|
float timenow;
|
|
|
|
int ifirst;
|
|
|
|
int ilast;
|
|
|
|
ListBase *do_effector;
|
|
|
|
int do_deflector;
|
|
|
|
float fieldfactor;
|
|
|
|
float windfactor;
|
|
|
|
int nr;
|
|
|
|
int tot;
|
2012-04-21 13:37:26 +00:00
|
|
|
} SB_thread_context;
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
#define MID_PRESERVE 1
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
#define SOFTGOALSNAP 0.999f
|
2005-11-19 21:35:06 +00:00
|
|
|
/* if bp-> goal is above make it a *forced follow original* and skip all ODE stuff for this bp
|
2012-09-28 06:45:20 +00:00
|
|
|
* removes *unnecessary* stiffness from ODE system
|
2012-05-01 17:51:03 +00:00
|
|
|
*/
|
2006-11-10 23:09:16 +00:00
|
|
|
#define HEUNWARNLIMIT 1 /* 500 would be fine i think for detecting severe *stiff* stuff */
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-04-18 21:51:45 +00:00
|
|
|
|
2006-10-10 21:49:02 +00:00
|
|
|
#define BSF_INTERSECT 1 /* edge intersects collider face */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
/* private definitions for bodypoint states */
|
|
|
|
#define SBF_DOFUZZY 1 /* Bodypoint do fuzzy */
|
|
|
|
#define SBF_OUTOFCOLLISION 2 /* Bodypoint does not collide */
|
|
|
|
|
2008-01-31 23:00:08 +00:00
|
|
|
|
|
|
|
#define BFF_INTERSECT 1 /* collider edge intrudes face */
|
|
|
|
#define BFF_CLOSEVERT 2 /* collider vertex repulses face */
|
2006-10-10 21:49:02 +00:00
|
|
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
static float SoftHeunTol = 1.0f; /* humm .. this should be calculated from sb parameters and sizes */
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-03-09 19:45:59 +00:00
|
|
|
/* local prototypes */
|
2005-04-02 13:57:23 +00:00
|
|
|
static void free_softbody_intern(SoftBody *sb);
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-04-12 21:36:21 +00:00
|
|
|
/*+++ frame based timing +++*/
|
|
|
|
|
2005-11-19 21:35:06 +00:00
|
|
|
/*physical unit of force is [kg * m / sec^2]*/
|
2005-04-12 21:36:21 +00:00
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static float sb_grav_force_scale(Object *UNUSED(ob))
|
2005-11-19 21:35:06 +00:00
|
|
|
/* since unit of g is [m/sec^2] and F = mass * g we rescale unit mass of node to 1 gramm
|
2012-05-01 17:51:03 +00:00
|
|
|
* put it to a function here, so we can add user options later without touching simulation code
|
|
|
|
*/
|
2005-04-12 21:36:21 +00:00
|
|
|
{
|
|
|
|
return (0.001f);
|
|
|
|
}
|
|
|
|
|
2010-10-16 14:32:17 +00:00
|
|
|
static float sb_fric_force_scale(Object *UNUSED(ob))
|
2005-11-19 21:35:06 +00:00
|
|
|
/* rescaling unit of drag [1 / sec] to somehow reasonable
|
2012-05-01 17:51:03 +00:00
|
|
|
* put it to a function here, so we can add user options later without touching simulation code
|
|
|
|
*/
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
2005-04-12 21:36:21 +00:00
|
|
|
return (0.01f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static float sb_time_scale(Object *ob)
|
2005-11-19 21:35:06 +00:00
|
|
|
/* defining the frames to *real* time relation */
|
2005-04-12 21:36:21 +00:00
|
|
|
{
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb) {
|
2010-06-14 23:56:12 +00:00
|
|
|
return(sb->physics_speed);
|
2013-03-15 10:48:48 +00:00
|
|
|
/* hrms .. this could be IPO as well :)
|
|
|
|
* estimated range [0.001 sluggish slug - 100.0 very fast (i hope ODE solver can handle that)]
|
|
|
|
* 1 approx = a unit 1 pendulum at g = 9.8 [earth conditions] has period 65 frames
|
|
|
|
* theory would give a 50 frames period .. so there must be something inaccurate .. looking for that (BM)
|
2005-11-19 21:35:06 +00:00
|
|
|
*/
|
2005-04-12 21:36:21 +00:00
|
|
|
}
|
|
|
|
return (1.0f);
|
2010-06-14 23:56:12 +00:00
|
|
|
/*
|
2013-03-15 10:48:48 +00:00
|
|
|
* this would be frames/sec independent timing assuming 25 fps is default
|
|
|
|
* but does not work very well with NLA
|
|
|
|
* return (25.0f/scene->r.frs_sec)
|
|
|
|
*/
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2005-04-12 21:36:21 +00:00
|
|
|
/*--- frame based timing ---*/
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2010-03-13 19:12:54 +00:00
|
|
|
/* helper functions for everything is animatable jow_go_for2_5 +++++++*/
|
2010-03-13 02:43:25 +00:00
|
|
|
/* introducing them here, because i know: steps in properties ( at frame timing )
|
2012-05-01 17:51:03 +00:00
|
|
|
* will cause unwanted responses of the softbody system (which does inter frame calculations )
|
|
|
|
* so first 'cure' would be: interpolate linear in time ..
|
|
|
|
* Q: why do i write this?
|
|
|
|
* A: because it happend once, that some eger coder 'streamlined' code to fail.
|
|
|
|
* We DO linear interpolation for goals .. and i think we should do on animated properties as well
|
|
|
|
*/
|
2010-03-13 02:43:25 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
/* animate sb->maxgoal, sb->mingoal */
|
|
|
|
static float _final_goal(Object *ob, BodyPoint *bp)/*jow_go_for2_5 */
|
2010-03-13 02:43:25 +00:00
|
|
|
{
|
|
|
|
float f = -1999.99f;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob) {
|
2010-03-13 02:43:25 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (!(ob->softflag & OB_SB_GOAL)) return (0.0f);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb&&bp) {
|
2010-03-13 02:43:25 +00:00
|
|
|
if (bp->goal < 0.0f) return (0.0f);
|
2013-12-01 12:37:05 +11:00
|
|
|
f = sb->mingoal + bp->goal * fabsf(sb->maxgoal - sb->mingoal);
|
2010-03-13 19:12:54 +00:00
|
|
|
f = pow(f, 4.0f);
|
|
|
|
return (f);
|
2010-03-13 02:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-29 17:55:54 +00:00
|
|
|
printf("_final_goal failed! sb or bp ==NULL\n");
|
2010-03-13 02:43:25 +00:00
|
|
|
return f; /*using crude but spot able values some times helps debuggin */
|
|
|
|
}
|
2010-03-13 21:22:56 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static float _final_mass(Object *ob, BodyPoint *bp)
|
2010-03-13 21:22:56 +00:00
|
|
|
{
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob) {
|
2010-03-13 21:22:56 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb&&bp) {
|
2010-03-13 21:22:56 +00:00
|
|
|
return(bp->mass*sb->nodemass);
|
|
|
|
}
|
|
|
|
}
|
2012-04-29 17:55:54 +00:00
|
|
|
printf("_final_mass failed! sb or bp ==NULL\n");
|
2010-03-13 21:22:56 +00:00
|
|
|
return 1.0f;
|
|
|
|
}
|
2010-03-13 02:43:25 +00:00
|
|
|
/* helper functions for everything is animateble jow_go_for2_5 ------*/
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/*+++ collider caching and dicing +++*/
|
|
|
|
|
2006-02-01 09:46:34 +00:00
|
|
|
/********************
|
2006-10-14 19:03:06 +00:00
|
|
|
for each target object/face the axis aligned bounding box (AABB) is stored
|
2010-07-20 10:41:08 +00:00
|
|
|
faces parallel to global axes
|
2012-04-29 15:47:02 +00:00
|
|
|
so only simple "value" in [min, max] ckecks are used
|
2006-01-31 22:48:41 +00:00
|
|
|
float operations still
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* just an ID here to reduce the prob for killing objects
|
|
|
|
** ob->sumohandle points to we should not kill :)
|
2010-06-14 23:56:12 +00:00
|
|
|
*/
|
2011-02-13 10:52:18 +00:00
|
|
|
static const int CCD_SAVETY = 190561;
|
2006-01-31 22:48:41 +00:00
|
|
|
|
2012-04-21 13:37:26 +00:00
|
|
|
typedef struct ccdf_minmax {
|
|
|
|
float minx, miny, minz, maxx, maxy, maxz;
|
|
|
|
} ccdf_minmax;
|
2006-01-31 22:48:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct ccd_Mesh {
|
2015-07-31 14:00:07 +10:00
|
|
|
int mvert_num, tri_num;
|
|
|
|
const MVert *mvert;
|
|
|
|
const MVert *mprevvert;
|
|
|
|
const MVertTri *tri;
|
2006-01-31 22:48:41 +00:00
|
|
|
int savety;
|
|
|
|
ccdf_minmax *mima;
|
2006-10-10 21:49:02 +00:00
|
|
|
/* Axis Aligned Bounding Box AABB */
|
2006-01-31 22:48:41 +00:00
|
|
|
float bbmin[3];
|
|
|
|
float bbmax[3];
|
2012-04-21 13:37:26 +00:00
|
|
|
} ccd_Mesh;
|
2006-01-31 22:48:41 +00:00
|
|
|
|
|
|
|
|
2011-07-08 13:22:58 +00:00
|
|
|
static ccd_Mesh *ccd_mesh_make(Object *ob)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
2011-07-08 13:22:58 +00:00
|
|
|
CollisionModifierData *cmd;
|
2010-03-22 09:30:00 +00:00
|
|
|
ccd_Mesh *pccd_M = NULL;
|
2015-07-31 14:00:07 +10:00
|
|
|
ccdf_minmax *mima;
|
|
|
|
const MVertTri *vt;
|
|
|
|
float hull;
|
2006-01-31 22:48:41 +00:00
|
|
|
int i;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-07-08 13:22:58 +00:00
|
|
|
cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* first some paranoia checks */
|
2011-07-08 13:22:58 +00:00
|
|
|
if (!cmd) return NULL;
|
2015-07-31 14:00:07 +10:00
|
|
|
if (!cmd->mvert_num || !cmd->tri_num) return NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
pccd_M = MEM_mallocN(sizeof(ccd_Mesh), "ccd_Mesh");
|
2015-07-31 14:00:07 +10:00
|
|
|
pccd_M->mvert_num = cmd->mvert_num;
|
|
|
|
pccd_M->tri_num = cmd->tri_num;
|
2006-01-31 22:48:41 +00:00
|
|
|
pccd_M->savety = CCD_SAVETY;
|
|
|
|
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
|
|
|
|
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
|
2006-11-10 23:09:16 +00:00
|
|
|
pccd_M->mprevvert=NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* blow it up with forcefield ranges */
|
2013-12-01 12:37:05 +11:00
|
|
|
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* alloc and copy verts*/
|
2011-07-08 13:22:58 +00:00
|
|
|
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
|
|
|
|
/* note that xnew coords are already in global space, */
|
|
|
|
/* determine the ortho BB */
|
2015-07-31 14:00:07 +10:00
|
|
|
for (i = 0; i < pccd_M->mvert_num; i++) {
|
|
|
|
const float *v;
|
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* evaluate limits */
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[i].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
|
|
|
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
|
|
|
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
|
|
|
|
pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
|
|
|
|
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
|
|
|
/* alloc and copy faces*/
|
2015-07-31 14:00:07 +10:00
|
|
|
pccd_M->tri = MEM_dupallocN(cmd->tri);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* OBBs for idea1 */
|
2015-07-31 14:00:07 +10:00
|
|
|
pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax) * pccd_M->tri_num, "ccd_Mesh_Faces_mima");
|
2006-01-31 22:48:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* anyhoo we need to walk the list of faces and find OBB they live in */
|
2015-07-31 14:00:07 +10:00
|
|
|
for (i = 0, mima = pccd_M->mima, vt = pccd_M->tri; i < pccd_M->tri_num; i++, mima++, vt++) {
|
|
|
|
const float *v;
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
mima->minx=mima->miny=mima->minz=1e30f;
|
|
|
|
mima->maxx=mima->maxy=mima->maxz=-1e30f;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[vt->tri[0]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[vt->tri[1]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[vt->tri[2]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
2013-12-01 12:37:05 +11:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
return pccd_M;
|
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
static void ccd_mesh_update(Object *ob, ccd_Mesh *pccd_M)
|
2006-01-31 22:48:41 +00:00
|
|
|
{
|
2011-07-08 13:22:58 +00:00
|
|
|
CollisionModifierData *cmd;
|
2015-07-31 14:00:07 +10:00
|
|
|
ccdf_minmax *mima;
|
|
|
|
const MVertTri *vt;
|
|
|
|
float hull;
|
2006-01-31 22:48:41 +00:00
|
|
|
int i;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-07-08 13:22:58 +00:00
|
|
|
cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* first some paranoia checks */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (!cmd) return;
|
2015-07-31 14:00:07 +10:00
|
|
|
if (!cmd->mvert_num || !cmd->tri_num) return;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
if ((pccd_M->mvert_num != cmd->mvert_num) ||
|
|
|
|
(pccd_M->tri_num != cmd->tri_num))
|
2012-04-28 06:31:57 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
|
|
|
|
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* blow it up with forcefield ranges */
|
2013-12-01 12:37:05 +11:00
|
|
|
hull = max_ff(ob->pd->pdef_sbift, ob->pd->pdef_sboft);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* rotate current to previous */
|
2015-07-31 14:00:07 +10:00
|
|
|
if (pccd_M->mprevvert) MEM_freeN((void *)pccd_M->mprevvert);
|
2010-03-22 09:30:00 +00:00
|
|
|
pccd_M->mprevvert = pccd_M->mvert;
|
2006-01-31 22:48:41 +00:00
|
|
|
/* alloc and copy verts*/
|
2011-07-08 13:22:58 +00:00
|
|
|
pccd_M->mvert = MEM_dupallocN(cmd->xnew);
|
|
|
|
/* note that xnew coords are already in global space, */
|
|
|
|
/* determine the ortho BB */
|
2015-07-31 14:00:07 +10:00
|
|
|
for (i=0; i < pccd_M->mvert_num; i++) {
|
|
|
|
const float *v;
|
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* evaluate limits */
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[i].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
|
|
|
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
|
|
|
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
|
|
|
|
pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
|
|
|
|
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* evaluate limits */
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mprevvert[i].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmin[0] = min_ff(pccd_M->bbmin[0], v[0] - hull);
|
|
|
|
pccd_M->bbmin[1] = min_ff(pccd_M->bbmin[1], v[1] - hull);
|
|
|
|
pccd_M->bbmin[2] = min_ff(pccd_M->bbmin[2], v[2] - hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2013-12-01 12:37:05 +11:00
|
|
|
pccd_M->bbmax[0] = max_ff(pccd_M->bbmax[0], v[0] + hull);
|
|
|
|
pccd_M->bbmax[1] = max_ff(pccd_M->bbmax[1], v[1] + hull);
|
|
|
|
pccd_M->bbmax[2] = max_ff(pccd_M->bbmax[2], v[2] + hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* anyhoo we need to walk the list of faces and find OBB they live in */
|
2015-07-31 14:00:07 +10:00
|
|
|
for (i = 0, mima = pccd_M->mima, vt = pccd_M->tri; i < pccd_M->tri_num; i++, mima++, vt++) {
|
|
|
|
const float *v;
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
mima->minx=mima->miny=mima->minz=1e30f;
|
|
|
|
mima->maxx=mima->maxy=mima->maxz=-1e30f;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
/* mvert */
|
|
|
|
v = pccd_M->mvert[vt->tri[0]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[vt->tri[1]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mvert[vt->tri[2]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
/* mprevvert */
|
|
|
|
v = pccd_M->mprevvert[vt->tri[0]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mprevvert[vt->tri[1]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2012-04-29 15:47:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
v = pccd_M->mprevvert[vt->tri[2]].co;
|
2013-12-01 12:37:05 +11:00
|
|
|
mima->minx = min_ff(mima->minx, v[0] - hull);
|
|
|
|
mima->miny = min_ff(mima->miny, v[1] - hull);
|
|
|
|
mima->minz = min_ff(mima->minz, v[2] - hull);
|
|
|
|
mima->maxx = max_ff(mima->maxx, v[0] + hull);
|
|
|
|
mima->maxy = max_ff(mima->maxy, v[1] + hull);
|
|
|
|
mima->maxz = max_ff(mima->maxz, v[2] + hull);
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
return;
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void ccd_mesh_free(ccd_Mesh *ccdm)
|
2006-01-31 22:48:41 +00:00
|
|
|
{
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm && (ccdm->savety == CCD_SAVETY )) { /*make sure we're not nuking objects we don't know*/
|
2015-07-31 14:00:07 +10:00
|
|
|
MEM_freeN((void *)ccdm->mvert);
|
|
|
|
MEM_freeN((void *)ccdm->tri);
|
|
|
|
if (ccdm->mprevvert) MEM_freeN((void *)ccdm->mprevvert);
|
2006-01-31 22:48:41 +00:00
|
|
|
MEM_freeN(ccdm->mima);
|
|
|
|
MEM_freeN(ccdm);
|
|
|
|
ccdm = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 18:56:44 +10:00
|
|
|
static void ccd_build_deflector_hash_single(GHash *hash, Object *ob)
|
|
|
|
{
|
|
|
|
/* only with deflecting set */
|
|
|
|
if (ob->pd && ob->pd->deflect) {
|
|
|
|
void **val_p;
|
|
|
|
if (!BLI_ghash_ensure_p(hash, ob, &val_p)) {
|
|
|
|
ccd_Mesh *ccdmesh = ccd_mesh_make(ob);
|
|
|
|
*val_p = ccdmesh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
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
|
|
|
* \note collection overrides scene when not NULL.
|
2016-07-31 18:56:44 +10:00
|
|
|
*/
|
2018-06-08 19:26:46 +02:00
|
|
|
static void ccd_build_deflector_hash(Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash)
|
2006-01-31 22:48:41 +00:00
|
|
|
{
|
2006-11-10 23:09:16 +00:00
|
|
|
if (!hash) return;
|
2016-07-31 18:56:44 +10:00
|
|
|
|
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
|
|
|
/* Explicit collision collection. */
|
2018-06-08 19:26:46 +02:00
|
|
|
Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
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
|
|
|
for (; base; base = base->next) {
|
2017-12-01 11:24:21 -02:00
|
|
|
/* Only proceed for mesh object in same layer. */
|
|
|
|
if (base->object->type == OB_MESH) {
|
2018-06-08 19:26:46 +02:00
|
|
|
Object *ob = base->object;
|
2017-12-01 11:24:21 -02:00
|
|
|
if (ob == vertexowner) {
|
|
|
|
/* If vertexowner is given we don't want to check collision with owner object. */
|
|
|
|
continue;
|
2016-07-31 18:56:44 +10:00
|
|
|
}
|
2017-12-01 11:24:21 -02:00
|
|
|
ccd_build_deflector_hash_single(hash, ob);
|
2016-07-31 18:56:44 +10:00
|
|
|
}
|
|
|
|
}
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
|
|
|
|
2016-07-31 18:56:44 +10:00
|
|
|
static void ccd_update_deflector_hash_single(GHash *hash, Object *ob)
|
|
|
|
{
|
|
|
|
if (ob->pd && ob->pd->deflect) {
|
|
|
|
ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash, ob);
|
|
|
|
if (ccdmesh) {
|
|
|
|
ccd_mesh_update(ob, ccdmesh);
|
|
|
|
}
|
|
|
|
}
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
|
|
|
|
2016-07-31 18:56:44 +10:00
|
|
|
/**
|
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
|
|
|
* \note collection overrides scene when not NULL.
|
2016-07-31 18:56:44 +10:00
|
|
|
*/
|
2018-06-08 19:26:46 +02:00
|
|
|
static void ccd_update_deflector_hash(Depsgraph *depsgraph, Collection *collection, Object *vertexowner, GHash *hash)
|
2006-01-31 22:48:41 +00:00
|
|
|
{
|
2006-12-02 18:42:20 +00:00
|
|
|
if ((!hash) || (!vertexowner)) return;
|
2016-07-31 18:56:44 +10:00
|
|
|
|
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
|
|
|
/* Explicit collision collection. */
|
2018-06-08 19:26:46 +02:00
|
|
|
Base *base = BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection);
|
2016-07-31 18:56:44 +10:00
|
|
|
|
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
|
|
|
for (; base; base = base->next) {
|
2017-12-01 11:24:21 -02:00
|
|
|
/* Only proceed for mesh object in same layer. */
|
|
|
|
if (base->object->type == OB_MESH) {
|
2018-06-08 19:26:46 +02:00
|
|
|
Object *ob = base->object;
|
2017-12-01 11:24:21 -02:00
|
|
|
if (ob == vertexowner) {
|
|
|
|
/* If vertexowner is given we don't want to check collision with owner object. */
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2017-12-01 11:24:21 -02:00
|
|
|
}
|
2006-01-31 22:48:41 +00:00
|
|
|
|
2016-07-31 18:56:44 +10:00
|
|
|
ccd_update_deflector_hash_single(hash, ob);
|
|
|
|
}
|
|
|
|
}
|
2006-01-31 22:48:41 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/*--- collider caching and dicing ---*/
|
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
static int count_mesh_quads(Mesh *me)
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
int a, result = 0;
|
2015-07-31 19:17:06 +10:00
|
|
|
const MPoly *mp = me->mpoly;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 19:17:06 +10:00
|
|
|
if (mp) {
|
|
|
|
for (a = me->totpoly; a > 0; a--, mp++) {
|
|
|
|
if (mp->totloop == 4) {
|
|
|
|
result++;
|
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
static void add_mesh_quad_diag_springs(Object *ob)
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
|
|
|
Mesh *me= ob->data;
|
2011-05-22 16:29:51 +00:00
|
|
|
/*BodyPoint *bp;*/ /*UNUSED*/
|
2012-02-27 10:35:39 +00:00
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->soft) {
|
2005-04-02 13:57:23 +00:00
|
|
|
int nofquads;
|
2009-11-11 09:59:51 +00:00
|
|
|
//float s_shear = ob->soft->shearstiff*ob->soft->shearstiff;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
nofquads = count_mesh_quads(me);
|
2005-01-12 22:28:13 +00:00
|
|
|
if (nofquads) {
|
2015-07-31 19:17:06 +10:00
|
|
|
const MLoop *mloop = me->mloop;
|
|
|
|
const MPoly *mp = me->mpoly;
|
|
|
|
BodySpring *bs;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 19:17:06 +10:00
|
|
|
/* resize spring-array to hold additional quad springs */
|
|
|
|
ob->soft->bspring = MEM_recallocN(ob->soft->bspring, sizeof(BodySpring) * (ob->soft->totspring + nofquads * 2));
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/* fill the tail */
|
|
|
|
a = 0;
|
2015-07-31 19:17:06 +10:00
|
|
|
bs = &ob->soft->bspring[ob->soft->totspring];
|
2011-05-22 16:29:51 +00:00
|
|
|
/*bp= ob->soft->bpoint; */ /*UNUSED*/
|
2015-07-31 19:17:06 +10:00
|
|
|
for (a = me->totpoly; a > 0; a--, mp++) {
|
|
|
|
if (mp->totloop == 4) {
|
|
|
|
bs->v1 = mloop[mp->loopstart + 0].v;
|
|
|
|
bs->v2 = mloop[mp->loopstart + 2].v;
|
|
|
|
bs->springtype = SB_STIFFQUAD;
|
|
|
|
bs++;
|
|
|
|
bs->v1 = mloop[mp->loopstart + 1].v;
|
|
|
|
bs->v2 = mloop[mp->loopstart + 3].v;
|
|
|
|
bs->springtype = SB_STIFFQUAD;
|
|
|
|
bs++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* now we can announce new springs */
|
2015-07-31 19:17:06 +10:00
|
|
|
ob->soft->totspring += nofquads * 2;
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void add_2nd_order_roller(Object *ob, float UNUSED(stiffness), int *counter, int addsprings)
|
2006-09-26 12:53:57 +00:00
|
|
|
{
|
|
|
|
/*assume we have a softbody*/
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2012-04-29 15:47:02 +00:00
|
|
|
BodyPoint *bp, *bpo;
|
|
|
|
BodySpring *bs, *bs2, *bs3= NULL;
|
|
|
|
int a, b, c, notthis= 0, v0;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (!sb->bspring) {return;} /* we are 2nd order here so 1rst should have been build :) */
|
2006-09-26 12:53:57 +00:00
|
|
|
/* first run counting second run adding */
|
|
|
|
*counter = 0;
|
|
|
|
if (addsprings) bs3 = ob->soft->bspring+ob->soft->totspring;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2006-09-26 12:53:57 +00:00
|
|
|
/*scan for neighborhood*/
|
|
|
|
bpo = NULL;
|
|
|
|
v0 = (sb->totpoint-a);
|
2012-02-27 10:35:39 +00:00
|
|
|
for (b=bp->nofsprings;b>0;b--) {
|
2006-09-26 12:53:57 +00:00
|
|
|
bs = sb->bspring + bp->springs[b-1];
|
|
|
|
/*nasty thing here that springs have two ends
|
|
|
|
so here we have to make sure we examine the other */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (v0 == bs->v1) {
|
2012-02-23 02:17:50 +00:00
|
|
|
bpo = sb->bpoint+bs->v2;
|
2006-09-26 12:53:57 +00:00
|
|
|
notthis = bs->v2;
|
|
|
|
}
|
|
|
|
else {
|
2018-04-16 17:08:27 +02:00
|
|
|
if (v0 == bs->v2) {
|
|
|
|
bpo = sb->bpoint+bs->v1;
|
|
|
|
notthis = bs->v1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("oops we should not get here - add_2nd_order_springs");
|
|
|
|
}
|
2006-09-26 12:53:57 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bpo) {/* so now we have a 2nd order humpdidump */
|
|
|
|
for (c=bpo->nofsprings;c>0;c--) {
|
2006-09-26 12:53:57 +00:00
|
|
|
bs2 = sb->bspring + bpo->springs[c-1];
|
2012-05-20 19:49:27 +00:00
|
|
|
if ((bs2->v1 != notthis) && (bs2->v1 > v0)) {
|
2006-09-26 12:53:57 +00:00
|
|
|
(*counter)++;/*hit */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (addsprings) {
|
2006-09-26 12:53:57 +00:00
|
|
|
bs3->v1= v0;
|
|
|
|
bs3->v2= bs2->v1;
|
2012-02-23 02:17:50 +00:00
|
|
|
bs3->springtype = SB_BEND;
|
2006-09-26 12:53:57 +00:00
|
|
|
bs3++;
|
|
|
|
}
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if ((bs2->v2 !=notthis)&&(bs2->v2 > v0)) {
|
2015-03-11 13:14:24 +11:00
|
|
|
(*counter)++; /* hit */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (addsprings) {
|
2006-09-26 12:53:57 +00:00
|
|
|
bs3->v1= v0;
|
|
|
|
bs3->v2= bs2->v2;
|
2012-02-23 02:17:50 +00:00
|
|
|
bs3->springtype = SB_BEND;
|
2006-09-26 12:53:57 +00:00
|
|
|
bs3++;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-09-26 12:53:57 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-09-26 12:53:57 +00:00
|
|
|
}
|
|
|
|
/*scan for neighborhood done*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void add_2nd_order_springs(Object *ob, float stiffness)
|
2006-09-26 12:53:57 +00:00
|
|
|
{
|
|
|
|
int counter = 0;
|
|
|
|
BodySpring *bs_new;
|
2008-01-09 00:25:51 +00:00
|
|
|
stiffness *=stiffness;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
add_2nd_order_roller(ob, stiffness, &counter, 0); /* counting */
|
2006-09-26 12:53:57 +00:00
|
|
|
if (counter) {
|
|
|
|
/* resize spring-array to hold additional springs */
|
2012-04-29 17:11:40 +00:00
|
|
|
bs_new= MEM_callocN((ob->soft->totspring + counter )*sizeof(BodySpring), "bodyspring");
|
2012-04-29 15:47:02 +00:00
|
|
|
memcpy(bs_new, ob->soft->bspring, (ob->soft->totspring )*sizeof(BodySpring));
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->soft->bspring)
|
2010-06-14 23:56:12 +00:00
|
|
|
MEM_freeN(ob->soft->bspring);
|
|
|
|
ob->soft->bspring = bs_new;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
add_2nd_order_roller(ob, stiffness, &counter, 1); /* adding */
|
2012-02-27 10:35:39 +00:00
|
|
|
ob->soft->totspring += counter;
|
2006-09-26 12:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void add_bp_springlist(BodyPoint *bp, int springID)
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
|
|
|
int *newlist;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
if (bp->springs == NULL) {
|
2012-04-29 17:11:40 +00:00
|
|
|
bp->springs = MEM_callocN(sizeof(int), "bpsprings");
|
2005-01-12 22:28:13 +00:00
|
|
|
bp->springs[0] = springID;
|
|
|
|
bp->nofsprings = 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bp->nofsprings++;
|
|
|
|
newlist = MEM_callocN(bp->nofsprings * sizeof(int), "bpsprings");
|
2012-04-29 15:47:02 +00:00
|
|
|
memcpy(newlist, bp->springs, (bp->nofsprings-1)* sizeof(int));
|
2005-01-12 22:28:13 +00:00
|
|
|
MEM_freeN(bp->springs);
|
|
|
|
bp->springs = newlist;
|
|
|
|
bp->springs[bp->nofsprings-1] = springID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do this once when sb is build
|
|
|
|
it is O(N^2) so scanning for springs every iteration is too expensive
|
|
|
|
*/
|
2005-04-02 13:57:23 +00:00
|
|
|
static void build_bps_springlist(Object *ob)
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2010-06-14 23:56:12 +00:00
|
|
|
BodyPoint *bp;
|
|
|
|
BodySpring *bs;
|
2012-04-29 15:47:02 +00:00
|
|
|
int a, b;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-11-19 21:35:06 +00:00
|
|
|
if (sb==NULL) return; /* paranoya check */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2006-09-27 06:59:27 +00:00
|
|
|
/* throw away old list */
|
|
|
|
if (bp->springs) {
|
|
|
|
MEM_freeN(bp->springs);
|
|
|
|
bp->springs=NULL;
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
/* scan for attached inner springs */
|
2012-02-23 02:17:50 +00:00
|
|
|
for (b=sb->totspring, bs= sb->bspring; b>0; b--, bs++) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (( (sb->totpoint-a) == bs->v1) ) {
|
2012-04-29 15:47:02 +00:00
|
|
|
add_bp_springlist(bp, sb->totspring -b);
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (( (sb->totpoint-a) == bs->v2) ) {
|
2012-04-29 15:47:02 +00:00
|
|
|
add_bp_springlist(bp, sb->totspring -b);
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2005-11-19 21:35:06 +00:00
|
|
|
}/*for springs*/
|
2010-06-14 23:56:12 +00:00
|
|
|
}/*for bp*/
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 20:27:46 +00:00
|
|
|
static void calculate_collision_balls(Object *ob)
|
|
|
|
{
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2010-06-14 23:56:12 +00:00
|
|
|
BodyPoint *bp;
|
|
|
|
BodySpring *bs;
|
2012-04-29 15:47:02 +00:00
|
|
|
int a, b, akku_count;
|
|
|
|
float min, max, akku;
|
2006-10-01 21:49:10 +00:00
|
|
|
|
2006-09-28 20:27:46 +00:00
|
|
|
if (sb==NULL) return; /* paranoya check */
|
2006-10-01 21:49:10 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2006-09-28 20:27:46 +00:00
|
|
|
bp->colball=0;
|
2006-10-04 21:36:55 +00:00
|
|
|
akku =0.0f;
|
|
|
|
akku_count=0;
|
2006-10-01 21:49:10 +00:00
|
|
|
min = 1e22f;
|
|
|
|
max = -1e22f;
|
|
|
|
/* first estimation based on attached */
|
2012-02-27 10:35:39 +00:00
|
|
|
for (b=bp->nofsprings;b>0;b--) {
|
2006-09-28 20:27:46 +00:00
|
|
|
bs = sb->bspring + bp->springs[b-1];
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bs->springtype == SB_EDGE) {
|
2013-12-01 12:37:05 +11:00
|
|
|
akku += bs->len;
|
|
|
|
akku_count++;
|
|
|
|
min = min_ff(bs->len, min);
|
|
|
|
max = max_ff(bs->len, max);
|
2006-10-04 21:36:55 +00:00
|
|
|
}
|
2006-10-01 21:49:10 +00:00
|
|
|
}
|
|
|
|
|
2006-10-04 21:36:55 +00:00
|
|
|
if (akku_count > 0) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->sbc_mode == SBC_MODE_MANUAL) {
|
2006-10-01 21:49:10 +00:00
|
|
|
bp->colball=sb->colball;
|
2006-10-10 21:49:02 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->sbc_mode == SBC_MODE_AVG) {
|
2007-11-16 12:23:00 +00:00
|
|
|
bp->colball = akku/(float)akku_count*sb->colball;
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->sbc_mode == SBC_MODE_MIN) {
|
2006-10-10 21:49:02 +00:00
|
|
|
bp->colball=min*sb->colball;
|
2007-11-16 12:23:00 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->sbc_mode == SBC_MODE_MAX) {
|
2006-10-10 21:49:02 +00:00
|
|
|
bp->colball=max*sb->colball;
|
2007-11-16 12:23:00 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->sbc_mode == SBC_MODE_AVGMINMAX) {
|
2007-11-16 12:23:00 +00:00
|
|
|
bp->colball = (min + max)/2.0f*sb->colball;
|
|
|
|
}
|
2006-09-28 20:27:46 +00:00
|
|
|
}
|
|
|
|
else bp->colball=0;
|
2010-06-14 23:56:12 +00:00
|
|
|
}/*for bp*/
|
2006-09-28 20:27:46 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* creates new softbody if didn't exist yet, makes new points and springs arrays */
|
2010-06-14 23:56:12 +00:00
|
|
|
static void renew_softbody(Scene *scene, Object *ob, int totpoint, int totspring)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2005-04-02 13:57:23 +00:00
|
|
|
SoftBody *sb;
|
2005-08-15 10:30:53 +00:00
|
|
|
int i;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
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 softflag;
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->soft==NULL) ob->soft= sbNew(scene);
|
2005-04-02 13:57:23 +00:00
|
|
|
else free_softbody_intern(ob->soft);
|
|
|
|
sb= ob->soft;
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
softflag=ob->softflag;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totpoint) {
|
2004-10-01 14:10:30 +00:00
|
|
|
sb->totpoint= totpoint;
|
|
|
|
sb->totspring= totspring;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 17:11:40 +00:00
|
|
|
sb->bpoint= MEM_mallocN(totpoint*sizeof(BodyPoint), "bodypoint");
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totspring)
|
2012-04-29 17:11:40 +00:00
|
|
|
sb->bspring= MEM_mallocN(totspring*sizeof(BodySpring), "bodyspring");
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2012-03-02 16:05:54 +00:00
|
|
|
/* initialize BodyPoint array */
|
2005-08-15 10:30:53 +00:00
|
|
|
for (i=0; i<totpoint; i++) {
|
|
|
|
BodyPoint *bp = &sb->bpoint[i];
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2010-03-13 19:12:54 +00:00
|
|
|
/* hum as far as i see this is overridden by _final_goal() now jow_go_for2_5 */
|
|
|
|
/* sadly breaks compatibility with older versions */
|
2010-06-14 23:56:12 +00:00
|
|
|
/* but makes goals behave the same for meshes, lattices and curves */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (softflag & OB_SB_GOAL) {
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
bp->goal= sb->defgoal;
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
else {
|
|
|
|
bp->goal= 0.0f;
|
2005-08-15 10:30:53 +00:00
|
|
|
/* so this will definily be below SOFTGOALSNAP */
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
bp->nofsprings= 0;
|
|
|
|
bp->springs= NULL;
|
2006-11-10 23:09:16 +00:00
|
|
|
bp->choke = 0.0f;
|
2008-01-31 23:00:08 +00:00
|
|
|
bp->choke2 = 0.0f;
|
|
|
|
bp->frozen = 1.0f;
|
2006-10-14 19:03:06 +00:00
|
|
|
bp->colball = 0.0f;
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->loc_flag = 0;
|
2009-08-21 12:49:21 +00:00
|
|
|
bp->springweight = 1.0f;
|
2010-03-13 21:22:56 +00:00
|
|
|
bp->mass = 1.0f;
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-02 13:28:13 +00:00
|
|
|
static void free_softbody_baked(SoftBody *sb)
|
|
|
|
{
|
|
|
|
SBVertex *key;
|
|
|
|
int k;
|
2005-09-20 10:21:30 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (k=0; k<sb->totkey; k++) {
|
2005-05-02 13:28:13 +00:00
|
|
|
key= *(sb->keys + k);
|
2012-02-23 02:17:50 +00:00
|
|
|
if (key) MEM_freeN(key);
|
2005-05-02 13:28:13 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->keys) MEM_freeN(sb->keys);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-05-02 13:28:13 +00:00
|
|
|
sb->keys= NULL;
|
|
|
|
sb->totkey= 0;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
static void free_scratch(SoftBody *sb)
|
|
|
|
{
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch) {
|
2006-11-10 23:09:16 +00:00
|
|
|
/* todo make sure everything is cleaned up nicly */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch->colliderhash) {
|
2007-03-16 05:03:38 +00:00
|
|
|
BLI_ghash_free(sb->scratch->colliderhash, NULL,
|
|
|
|
(GHashValFreeFP) ccd_mesh_free); /*this hoepfully will free all caches*/
|
2006-11-10 23:09:16 +00:00
|
|
|
sb->scratch->colliderhash = NULL;
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch->bodyface) {
|
2007-03-16 05:03:38 +00:00
|
|
|
MEM_freeN(sb->scratch->bodyface);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch->Ref.ivert) {
|
2009-11-21 22:45:25 +00:00
|
|
|
MEM_freeN(sb->scratch->Ref.ivert);
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
MEM_freeN(sb->scratch);
|
|
|
|
sb->scratch = NULL;
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-05-02 13:28:13 +00:00
|
|
|
}
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* only frees internal data */
|
|
|
|
static void free_softbody_intern(SoftBody *sb)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb) {
|
2005-01-12 22:28:13 +00:00
|
|
|
int a;
|
|
|
|
BodyPoint *bp;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->bpoint) {
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
/* free spring list */
|
2005-01-12 22:28:13 +00:00
|
|
|
if (bp->springs != NULL) {
|
|
|
|
MEM_freeN(bp->springs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MEM_freeN(sb->bpoint);
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->bspring) MEM_freeN(sb->bspring);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
sb->totpoint= sb->totspring= 0;
|
|
|
|
sb->bpoint= NULL;
|
|
|
|
sb->bspring= NULL;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
free_scratch(sb);
|
2005-05-02 13:28:13 +00:00
|
|
|
free_softbody_baked(sb);
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
|
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/* ************ dynamics ********** */
|
2006-01-31 22:48:41 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
/* the most general (micro physics correct) way to do collision
|
|
|
|
** (only needs the current particle position)
|
2006-01-31 22:48:41 +00:00
|
|
|
**
|
2010-06-14 23:56:12 +00:00
|
|
|
** it actually checks if the particle intrudes a short range force field generated
|
2006-01-31 22:48:41 +00:00
|
|
|
** by the faces of the target object and returns a force to drive the particel out
|
|
|
|
** the strenght of the field grows exponetially if the particle is on the 'wrong' side of the face
|
|
|
|
** 'wrong' side : projection to the face normal is negative (all referred to a vertex in the face)
|
|
|
|
**
|
2010-06-14 23:56:12 +00:00
|
|
|
** flaw of this: 'fast' particles as well as 'fast' colliding faces
|
|
|
|
** give a 'tunnel' effect such that the particle passes through the force field
|
|
|
|
** without ever 'seeing' it
|
2006-01-31 22:48:41 +00:00
|
|
|
** this is fully compliant to heisenberg: h >= fuzzy(location) * fuzzy(time)
|
|
|
|
** besides our h is way larger than in QM because forces propagate way slower here
|
|
|
|
** we have to deal with fuzzy(time) in the range of 1/25 seconds (typical frame rate)
|
2010-06-14 23:56:12 +00:00
|
|
|
** yup collision targets are not known here any better
|
2006-01-31 22:48:41 +00:00
|
|
|
** and 1/25 second is looong compared to real collision events
|
2010-06-14 23:56:12 +00:00
|
|
|
** Q: why not use 'simple' collision here like bouncing back a particle
|
2006-01-31 22:48:41 +00:00
|
|
|
** --> reverting is velocity on the face normal
|
2010-06-14 23:56:12 +00:00
|
|
|
** A: because our particles are not alone here
|
2012-03-09 00:41:09 +00:00
|
|
|
** and need to tell their neighbors exactly what happens via spring forces
|
2006-01-31 22:48:41 +00:00
|
|
|
** unless sbObjectStep( .. ) is called on sub frame timing level
|
2010-06-14 23:56:12 +00:00
|
|
|
** BTW that also questions the use of a 'implicit' solvers on softbodies
|
2006-01-31 22:48:41 +00:00
|
|
|
** since that would only valid for 'slow' moving collision targets and dito particles
|
|
|
|
*/
|
|
|
|
|
2012-03-01 12:20:18 +00:00
|
|
|
/* +++ dependency information functions*/
|
2008-02-16 00:07:05 +00:00
|
|
|
|
2016-07-31 18:56:44 +10:00
|
|
|
/**
|
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
|
|
|
* \note collection overrides scene when not NULL.
|
2016-07-31 18:56:44 +10:00
|
|
|
*/
|
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
|
|
|
static bool are_there_deflectors(Base *first_base)
|
2006-10-10 21:49:02 +00:00
|
|
|
{
|
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
|
|
|
for (Base *base = first_base; base; base = base->next) {
|
2017-12-01 11:24:21 -02:00
|
|
|
if (base->object->pd) {
|
|
|
|
if (base->object->pd->deflect)
|
2006-11-10 23:09:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2016-07-31 18:56:44 +10:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-08 19:26:46 +02:00
|
|
|
static int query_external_colliders(Depsgraph *depsgraph, Collection *collection)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
2018-06-08 19:26:46 +02:00
|
|
|
return(are_there_deflectors(BKE_collection_or_layer_objects(depsgraph, NULL, NULL, collection)));
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2012-03-01 12:20:18 +00:00
|
|
|
/* --- dependency information functions*/
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2008-02-16 00:07:05 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* +++ the aabb "force" section*/
|
2012-04-29 17:11:40 +00:00
|
|
|
static int sb_detect_aabb_collisionCached(float UNUSED(force[3]), unsigned int UNUSED(par_layer), struct Object *vertexowner, float UNUSED(time))
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
2006-10-10 21:49:02 +00:00
|
|
|
Object *ob;
|
2006-11-10 23:09:16 +00:00
|
|
|
SoftBody *sb=vertexowner->soft;
|
|
|
|
GHash *hash;
|
|
|
|
GHashIterator *ihash;
|
2012-04-29 15:47:02 +00:00
|
|
|
float aabbmin[3], aabbmax[3];
|
2011-05-22 16:29:51 +00:00
|
|
|
int deflected=0;
|
|
|
|
#if 0
|
|
|
|
int a;
|
|
|
|
#endif
|
2006-10-10 21:49:02 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
if ((sb == NULL) || (sb->scratch ==NULL)) return 0;
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(aabbmin, sb->scratch->aabbmin);
|
|
|
|
copy_v3_v3(aabbmax, sb->scratch->aabbmax);
|
2006-10-10 21:49:02 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
hash = vertexowner->soft->scratch->colliderhash;
|
|
|
|
ihash = BLI_ghashIterator_new(hash);
|
2013-05-08 12:58:11 +00:00
|
|
|
while (!BLI_ghashIterator_done(ihash)) {
|
2006-10-10 21:49:02 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
|
|
|
|
ob = BLI_ghashIterator_getKey (ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
{
|
2006-10-10 21:49:02 +00:00
|
|
|
/* only with deflecting set */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->pd && ob->pd->deflect) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm) {
|
2010-06-14 23:56:12 +00:00
|
|
|
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
2012-05-24 16:35:45 +00:00
|
|
|
(aabbmax[1] < ccdm->bbmin[1]) ||
|
|
|
|
(aabbmax[2] < ccdm->bbmin[2]) ||
|
|
|
|
(aabbmin[0] > ccdm->bbmax[0]) ||
|
|
|
|
(aabbmin[1] > ccdm->bbmax[1]) ||
|
|
|
|
(aabbmin[2] > ccdm->bbmax[2]) )
|
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
/* boxes don't intersect */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
/* so now we have the 2 boxes overlapping */
|
2010-03-22 09:30:00 +00:00
|
|
|
/* forces actually not used */
|
2006-11-10 23:09:16 +00:00
|
|
|
deflected = 2;
|
|
|
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2006-11-10 23:09:16 +00:00
|
|
|
/*aye that should be cached*/
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("missing cache error\n");
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
} /* if (ob->pd && ob->pd->deflect) */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
} /* while () */
|
|
|
|
BLI_ghashIterator_free(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
return deflected;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
/* --- the aabb section*/
|
|
|
|
|
|
|
|
|
|
|
|
/* +++ the face external section*/
|
2012-04-29 15:47:02 +00:00
|
|
|
static int sb_detect_face_pointCached(float face_v1[3], float face_v2[3], float face_v3[3], float *damp,
|
|
|
|
float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time)
|
|
|
|
{
|
2008-01-31 23:00:08 +00:00
|
|
|
Object *ob;
|
|
|
|
GHash *hash;
|
|
|
|
GHashIterator *ihash;
|
2012-04-29 15:47:02 +00:00
|
|
|
float nv1[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3];
|
|
|
|
float facedist, outerfacethickness, tune = 10.f;
|
2008-01-31 23:00:08 +00:00
|
|
|
int a, deflected=0;
|
|
|
|
|
2012-12-21 05:07:26 +00:00
|
|
|
aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]);
|
|
|
|
aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]);
|
|
|
|
aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]);
|
|
|
|
aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]);
|
|
|
|
aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]);
|
|
|
|
aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]);
|
2008-01-31 23:00:08 +00:00
|
|
|
|
|
|
|
/* calculate face normal once again SIGH */
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3v3(edge1, face_v1, face_v2);
|
|
|
|
sub_v3_v3v3(edge2, face_v3, face_v2);
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(d_nvect, edge2, edge1);
|
|
|
|
normalize_v3(d_nvect);
|
2008-01-31 23:00:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
hash = vertexowner->soft->scratch->colliderhash;
|
|
|
|
ihash = BLI_ghashIterator_new(hash);
|
2013-05-08 12:58:11 +00:00
|
|
|
while (!BLI_ghashIterator_done(ihash)) {
|
2008-01-31 23:00:08 +00:00
|
|
|
|
|
|
|
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
|
|
|
|
ob = BLI_ghashIterator_getKey (ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
{
|
2008-01-31 23:00:08 +00:00
|
|
|
/* only with deflecting set */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->pd && ob->pd->deflect) {
|
2015-07-31 14:00:07 +10:00
|
|
|
const MVert *mvert= NULL;
|
|
|
|
const MVert *mprevvert= NULL;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm) {
|
2015-07-31 14:00:07 +10:00
|
|
|
mvert = ccdm->mvert;
|
|
|
|
a = ccdm->mvert_num;
|
2010-06-14 23:56:12 +00:00
|
|
|
mprevvert= ccdm->mprevvert;
|
2012-02-23 02:17:50 +00:00
|
|
|
outerfacethickness = ob->pd->pdef_sboft;
|
2010-06-14 23:56:12 +00:00
|
|
|
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
2012-05-24 16:35:45 +00:00
|
|
|
(aabbmax[1] < ccdm->bbmin[1]) ||
|
|
|
|
(aabbmax[2] < ccdm->bbmin[2]) ||
|
|
|
|
(aabbmin[0] > ccdm->bbmax[0]) ||
|
|
|
|
(aabbmin[1] > ccdm->bbmax[1]) ||
|
|
|
|
(aabbmin[2] > ccdm->bbmax[2]) )
|
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
/* boxes don't intersect */
|
2008-01-31 23:00:08 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-01-31 23:00:08 +00:00
|
|
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2008-01-31 23:00:08 +00:00
|
|
|
/*aye that should be cached*/
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("missing cache error\n");
|
2008-01-31 23:00:08 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* use mesh*/
|
|
|
|
if (mvert) {
|
2012-03-24 06:18:31 +00:00
|
|
|
while (a) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(nv1, mvert[a-1].co);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mprevvert) {
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv1, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv1, mprevvert[a - 1].co, 1.0f - time);
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
|
|
|
/* origin to face_v2*/
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3(nv1, face_v2);
|
2012-04-29 15:47:02 +00:00
|
|
|
facedist = dot_v3v3(nv1, d_nvect);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ABS(facedist)<outerfacethickness) {
|
2012-04-29 15:47:02 +00:00
|
|
|
if (isect_point_tri_prism_v3(nv1, face_v1, face_v2, face_v3) ) {
|
2008-01-31 23:00:08 +00:00
|
|
|
float df;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (facedist > 0) {
|
2008-01-31 23:00:08 +00:00
|
|
|
df = (outerfacethickness-facedist)/outerfacethickness;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
df = (outerfacethickness+facedist)/outerfacethickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
*damp=df*tune*ob->pd->pdef_sbdamp;
|
|
|
|
|
2012-11-04 07:18:29 +00:00
|
|
|
df = 0.01f * expf(-100.0f * df);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(force, d_nvect, -df);
|
2008-01-31 23:00:08 +00:00
|
|
|
deflected = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
a--;
|
2012-03-24 06:18:31 +00:00
|
|
|
}/* while (a)*/
|
2008-01-31 23:00:08 +00:00
|
|
|
} /* if (mvert) */
|
2012-02-23 02:17:50 +00:00
|
|
|
} /* if (ob->pd && ob->pd->deflect) */
|
2008-01-31 23:00:08 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
}
|
2008-01-31 23:00:08 +00:00
|
|
|
} /* while () */
|
|
|
|
BLI_ghashIterator_free(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
return deflected;
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static int sb_detect_face_collisionCached(float face_v1[3], float face_v2[3], float face_v3[3], float *damp,
|
|
|
|
float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
GHash *hash;
|
|
|
|
GHashIterator *ihash;
|
2015-07-31 14:00:07 +10:00
|
|
|
float nv1[3], nv2[3], nv3[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
float t, tune = 10.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
int a, deflected=0;
|
|
|
|
|
2012-12-21 05:07:26 +00:00
|
|
|
aabbmin[0] = min_fff(face_v1[0], face_v2[0], face_v3[0]);
|
|
|
|
aabbmin[1] = min_fff(face_v1[1], face_v2[1], face_v3[1]);
|
|
|
|
aabbmin[2] = min_fff(face_v1[2], face_v2[2], face_v3[2]);
|
|
|
|
aabbmax[0] = max_fff(face_v1[0], face_v2[0], face_v3[0]);
|
|
|
|
aabbmax[1] = max_fff(face_v1[1], face_v2[1], face_v3[1]);
|
|
|
|
aabbmax[2] = max_fff(face_v1[2], face_v2[2], face_v3[2]);
|
2006-10-10 21:49:02 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
hash = vertexowner->soft->scratch->colliderhash;
|
|
|
|
ihash = BLI_ghashIterator_new(hash);
|
2013-05-08 12:58:11 +00:00
|
|
|
while (!BLI_ghashIterator_done(ihash)) {
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
|
|
|
|
ob = BLI_ghashIterator_getKey (ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
{
|
2006-11-10 23:09:16 +00:00
|
|
|
/* only with deflecting set */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->pd && ob->pd->deflect) {
|
2015-07-31 14:00:07 +10:00
|
|
|
const MVert *mvert = NULL;
|
|
|
|
const MVert *mprevvert = NULL;
|
|
|
|
const MVertTri *vt = NULL;
|
|
|
|
const ccdf_minmax *mima = NULL;
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm) {
|
2015-07-31 14:00:07 +10:00
|
|
|
mvert = ccdm->mvert;
|
|
|
|
vt = ccdm->tri;
|
|
|
|
mprevvert = ccdm->mprevvert;
|
|
|
|
mima = ccdm->mima;
|
|
|
|
a = ccdm->tri_num;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
2012-05-24 16:35:45 +00:00
|
|
|
(aabbmax[1] < ccdm->bbmin[1]) ||
|
|
|
|
(aabbmax[2] < ccdm->bbmin[2]) ||
|
|
|
|
(aabbmin[0] > ccdm->bbmax[0]) ||
|
|
|
|
(aabbmin[1] > ccdm->bbmax[1]) ||
|
|
|
|
(aabbmin[2] > ccdm->bbmax[2]) )
|
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
/* boxes don't intersect */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-10-10 21:49:02 +00:00
|
|
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2006-10-10 21:49:02 +00:00
|
|
|
/*aye that should be cached*/
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("missing cache error\n");
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2006-10-10 21:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* use mesh*/
|
|
|
|
while (a--) {
|
2015-07-31 14:00:07 +10:00
|
|
|
if ((aabbmax[0] < mima->minx) ||
|
|
|
|
(aabbmin[0] > mima->maxx) ||
|
|
|
|
(aabbmax[1] < mima->miny) ||
|
|
|
|
(aabbmin[1] > mima->maxy) ||
|
|
|
|
(aabbmax[2] < mima->minz) ||
|
|
|
|
(aabbmin[2] > mima->maxz))
|
|
|
|
{
|
2006-10-10 21:49:02 +00:00
|
|
|
mima++;
|
2015-07-31 14:00:07 +10:00
|
|
|
vt++;
|
2006-10-10 21:49:02 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mvert) {
|
2006-10-10 21:49:02 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
copy_v3_v3(nv1, mvert[vt->tri[0]].co);
|
|
|
|
copy_v3_v3(nv2, mvert[vt->tri[1]].co);
|
|
|
|
copy_v3_v3(nv3, mvert[vt->tri[2]].co);
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mprevvert) {
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv1, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv2, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv3, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2006-10-10 21:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* switch origin to be nv2*/
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3v3(edge1, nv1, nv2);
|
|
|
|
sub_v3_v3v3(edge2, nv3, nv2);
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(d_nvect, edge2, edge1);
|
|
|
|
normalize_v3(d_nvect);
|
2015-12-15 18:14:22 +11:00
|
|
|
if (isect_line_segment_tri_v3(nv1, nv2, face_v1, face_v2, face_v3, &t, NULL) ||
|
|
|
|
isect_line_segment_tri_v3(nv2, nv3, face_v1, face_v2, face_v3, &t, NULL) ||
|
|
|
|
isect_line_segment_tri_v3(nv3, nv1, face_v1, face_v2, face_v3, &t, NULL) )
|
2015-07-31 14:00:07 +10:00
|
|
|
{
|
|
|
|
madd_v3_v3fl(force, d_nvect, -0.5f);
|
2008-01-31 23:00:08 +00:00
|
|
|
*damp=tune*ob->pd->pdef_sbdamp;
|
2006-11-10 23:09:16 +00:00
|
|
|
deflected = 2;
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
mima++;
|
2015-07-31 14:00:07 +10:00
|
|
|
vt++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}/* while a */
|
2012-02-23 02:17:50 +00:00
|
|
|
} /* if (ob->pd && ob->pd->deflect) */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
} /* while () */
|
|
|
|
BLI_ghashIterator_free(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
return deflected;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void scan_for_ext_face_forces(Object *ob, float timenow)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb = ob->soft;
|
|
|
|
BodyFace *bf;
|
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
float damp=0.0f, choke=1.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
float tune = -10.0f;
|
|
|
|
float feedback[3];
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb && sb->scratch->totface) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
bf = sb->scratch->bodyface;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<sb->scratch->totface; a++, bf++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
bf->ext_force[0]=bf->ext_force[1]=bf->ext_force[2]=0.0f;
|
2008-01-31 23:00:08 +00:00
|
|
|
/*+++edges intruding*/
|
2010-06-14 23:56:12 +00:00
|
|
|
bf->flag &= ~BFF_INTERSECT;
|
2015-07-31 14:00:07 +10:00
|
|
|
zero_v3(feedback);
|
|
|
|
if (sb_detect_face_collisionCached(
|
|
|
|
sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos,
|
|
|
|
&damp, feedback, ob->lay, ob, timenow))
|
2013-12-01 12:37:05 +11:00
|
|
|
{
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v1].force, feedback, tune);
|
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v2].force, feedback, tune);
|
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v3].force, feedback, tune);
|
|
|
|
// madd_v3_v3fl(bf->ext_force, feedback, tune);
|
2008-01-31 23:00:08 +00:00
|
|
|
bf->flag |= BFF_INTERSECT;
|
2013-12-01 12:37:05 +11:00
|
|
|
choke = min_ff(max_ff(damp, choke), 1.0f);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2008-01-31 23:00:08 +00:00
|
|
|
/*---edges intruding*/
|
|
|
|
|
|
|
|
/*+++ close vertices*/
|
2012-04-21 12:51:47 +00:00
|
|
|
if (( bf->flag & BFF_INTERSECT)==0) {
|
2008-01-31 23:00:08 +00:00
|
|
|
bf->flag &= ~BFF_CLOSEVERT;
|
|
|
|
tune = -1.0f;
|
2015-07-31 14:00:07 +10:00
|
|
|
zero_v3(feedback);
|
|
|
|
if (sb_detect_face_pointCached(
|
|
|
|
sb->bpoint[bf->v1].pos, sb->bpoint[bf->v2].pos, sb->bpoint[bf->v3].pos,
|
|
|
|
&damp, feedback, ob->lay, ob, timenow))
|
2013-12-01 12:37:05 +11:00
|
|
|
{
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v1].force, feedback, tune);
|
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v2].force, feedback, tune);
|
|
|
|
madd_v3_v3fl(sb->bpoint[bf->v3].force, feedback, tune);
|
|
|
|
// madd_v3_v3fl(bf->ext_force, feedback, tune);
|
2013-12-01 12:37:05 +11:00
|
|
|
bf->flag |= BFF_CLOSEVERT;
|
|
|
|
choke = min_ff(max_ff(damp, choke), 1.0f);
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*--- close vertices*/
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
bf = sb->scratch->bodyface;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<sb->scratch->totface; a++, bf++) {
|
2012-04-28 06:31:57 +00:00
|
|
|
if (( bf->flag & BFF_INTERSECT) || ( bf->flag & BFF_CLOSEVERT)) {
|
2013-12-01 12:37:05 +11:00
|
|
|
sb->bpoint[bf->v1].choke2 = max_ff(sb->bpoint[bf->v1].choke2, choke);
|
|
|
|
sb->bpoint[bf->v2].choke2 = max_ff(sb->bpoint[bf->v2].choke2, choke);
|
|
|
|
sb->bpoint[bf->v3].choke2 = max_ff(sb->bpoint[bf->v3].choke2, choke);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --- the face external section*/
|
|
|
|
|
|
|
|
|
|
|
|
/* +++ the spring external section*/
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static int sb_detect_edge_collisionCached(float edge_v1[3], float edge_v2[3], float *damp,
|
|
|
|
float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
|
|
|
Object *ob;
|
|
|
|
GHash *hash;
|
|
|
|
GHashIterator *ihash;
|
2015-07-31 14:00:07 +10:00
|
|
|
float nv1[3], nv2[3], nv3[3], edge1[3], edge2[3], d_nvect[3], aabbmin[3], aabbmax[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
float t, el;
|
2006-11-10 23:09:16 +00:00
|
|
|
int a, deflected=0;
|
|
|
|
|
2013-12-01 12:37:05 +11:00
|
|
|
minmax_v3v3_v3(aabbmin, aabbmax, edge_v1);
|
|
|
|
minmax_v3v3_v3(aabbmin, aabbmax, edge_v2);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
el = len_v3v3(edge_v1, edge_v2);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
hash = vertexowner->soft->scratch->colliderhash;
|
|
|
|
ihash = BLI_ghashIterator_new(hash);
|
2013-05-08 12:58:11 +00:00
|
|
|
while (!BLI_ghashIterator_done(ihash)) {
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
|
|
|
|
ob = BLI_ghashIterator_getKey (ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
{
|
2006-11-10 23:09:16 +00:00
|
|
|
/* only with deflecting set */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->pd && ob->pd->deflect) {
|
2015-07-31 14:00:07 +10:00
|
|
|
const MVert *mvert = NULL;
|
|
|
|
const MVert *mprevvert = NULL;
|
|
|
|
const MVertTri *vt = NULL;
|
|
|
|
const ccdf_minmax *mima = NULL;
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm) {
|
2015-07-31 14:00:07 +10:00
|
|
|
mvert = ccdm->mvert;
|
|
|
|
mprevvert = ccdm->mprevvert;
|
|
|
|
vt = ccdm->tri;
|
|
|
|
mima = ccdm->mima;
|
|
|
|
a = ccdm->tri_num;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
if ((aabbmax[0] < ccdm->bbmin[0]) ||
|
2012-05-24 16:35:45 +00:00
|
|
|
(aabbmax[1] < ccdm->bbmin[1]) ||
|
|
|
|
(aabbmax[2] < ccdm->bbmin[2]) ||
|
|
|
|
(aabbmin[0] > ccdm->bbmax[0]) ||
|
|
|
|
(aabbmin[1] > ccdm->bbmax[1]) ||
|
|
|
|
(aabbmin[2] > ccdm->bbmax[2]) )
|
|
|
|
{
|
2012-03-18 07:38:51 +00:00
|
|
|
/* boxes don't intersect */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2006-11-10 23:09:16 +00:00
|
|
|
/*aye that should be cached*/
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("missing cache error\n");
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* use mesh*/
|
|
|
|
while (a--) {
|
2015-07-31 14:00:07 +10:00
|
|
|
if ((aabbmax[0] < mima->minx) ||
|
|
|
|
(aabbmin[0] > mima->maxx) ||
|
|
|
|
(aabbmax[1] < mima->miny) ||
|
|
|
|
(aabbmin[1] > mima->maxy) ||
|
|
|
|
(aabbmax[2] < mima->minz) ||
|
|
|
|
(aabbmin[2] > mima->maxz))
|
2013-12-01 12:37:05 +11:00
|
|
|
{
|
2006-11-10 23:09:16 +00:00
|
|
|
mima++;
|
2015-07-31 14:00:07 +10:00
|
|
|
vt++;
|
2006-11-10 23:09:16 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mvert) {
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
copy_v3_v3(nv1, mvert[vt->tri[0]].co);
|
|
|
|
copy_v3_v3(nv2, mvert[vt->tri[1]].co);
|
|
|
|
copy_v3_v3(nv3, mvert[vt->tri[2]].co);
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mprevvert) {
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv1, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv2, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv3, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* switch origin to be nv2*/
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3v3(edge1, nv1, nv2);
|
|
|
|
sub_v3_v3v3(edge2, nv3, nv2);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(d_nvect, edge2, edge1);
|
|
|
|
normalize_v3(d_nvect);
|
2015-12-15 18:14:22 +11:00
|
|
|
if (isect_line_segment_tri_v3(edge_v1, edge_v2, nv1, nv2, nv3, &t, NULL)) {
|
2012-04-29 15:47:02 +00:00
|
|
|
float v1[3], v2[3];
|
|
|
|
float intrusiondepth, i1, i2;
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3v3(v1, edge_v1, nv2);
|
|
|
|
sub_v3_v3v3(v2, edge_v2, nv2);
|
2012-04-29 15:47:02 +00:00
|
|
|
i1 = dot_v3v3(v1, d_nvect);
|
|
|
|
i2 = dot_v3v3(v2, d_nvect);
|
2013-12-01 12:37:05 +11:00
|
|
|
intrusiondepth = -min_ff(i1, i2) / el;
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(force, d_nvect, intrusiondepth);
|
2006-10-10 21:49:02 +00:00
|
|
|
*damp=ob->pd->pdef_sbdamp;
|
|
|
|
deflected = 2;
|
|
|
|
}
|
2015-07-31 14:00:07 +10:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
mima++;
|
2015-07-31 14:00:07 +10:00
|
|
|
vt++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}/* while a */
|
2012-02-23 02:17:50 +00:00
|
|
|
} /* if (ob->pd && ob->pd->deflect) */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
} /* while () */
|
|
|
|
BLI_ghashIterator_free(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
return deflected;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, int ifirst, int ilast, struct ListBase *do_effector)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb = ob->soft;
|
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
float damp;
|
2006-11-10 23:09:16 +00:00
|
|
|
float feedback[3];
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb && sb->totspring) {
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=ifirst; a<ilast; a++) {
|
2006-11-10 23:09:16 +00:00
|
|
|
BodySpring *bs = &sb->bspring[a];
|
2010-06-14 23:56:12 +00:00
|
|
|
bs->ext_force[0]=bs->ext_force[1]=bs->ext_force[2]=0.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
feedback[0]=feedback[1]=feedback[2]=0.0f;
|
|
|
|
bs->flag &= ~BSF_INTERSECT;
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bs->springtype == SB_EDGE) {
|
2006-11-10 23:09:16 +00:00
|
|
|
/* +++ springs colliding */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGECOLL) {
|
2012-04-29 15:47:02 +00:00
|
|
|
if ( sb_detect_edge_collisionCached (sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos,
|
|
|
|
&damp, feedback, ob->lay, ob, timenow)) {
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(bs->ext_force, feedback);
|
2006-11-10 23:09:16 +00:00
|
|
|
bs->flag |= BSF_INTERSECT;
|
|
|
|
//bs->cf=damp;
|
2010-03-22 09:30:00 +00:00
|
|
|
bs->cf=sb->choke*0.01f;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* ---- springs colliding */
|
|
|
|
|
|
|
|
/* +++ springs seeing wind ... n stuff depending on their orientation*/
|
2010-06-14 23:56:12 +00:00
|
|
|
/* note we don't use sb->mediafrict but use sb->aeroedge for magnitude of effect*/
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->aeroedge) {
|
2012-04-29 15:47:02 +00:00
|
|
|
float vel[3], sp[3], pr[3], force[3];
|
|
|
|
float f, windfactor = 0.25f;
|
2006-11-10 23:09:16 +00:00
|
|
|
/*see if we have wind*/
|
2012-02-23 02:17:50 +00:00
|
|
|
if (do_effector) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
EffectedPoint epoint;
|
2012-10-22 08:15:51 +00:00
|
|
|
float speed[3] = {0.0f, 0.0f, 0.0f};
|
2006-11-10 23:09:16 +00:00
|
|
|
float pos[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos);
|
|
|
|
mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pd_point_from_soft(scene, pos, vel, -1, &epoint);
|
|
|
|
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(speed, windfactor);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(vel, speed);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
/* media in rest */
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-04-29 15:47:02 +00:00
|
|
|
add_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2009-11-10 20:43:45 +00:00
|
|
|
f = normalize_v3(vel);
|
2006-11-10 23:09:16 +00:00
|
|
|
f = -0.0001f*f*f*sb->aeroedge;
|
2012-03-01 12:20:18 +00:00
|
|
|
/* (todo) add a nice angle dependent function done for now BUT */
|
2010-06-14 23:56:12 +00:00
|
|
|
/* still there could be some nice drag/lift function, but who needs it */
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(sp, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos);
|
|
|
|
project_v3_v3v3(pr, vel, sp);
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3(vel, pr);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(vel);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_AERO_ANGLE) {
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(sp);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bs->ext_force, vel, f * (1.0f - fabsf(dot_v3v3(vel, sp))));
|
2008-01-12 01:26:40 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bs->ext_force, vel, f); // to keep compatible with 2.45 release files
|
2008-01-12 01:26:40 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
/* --- springs seeing wind */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void scan_for_ext_spring_forces(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float timenow)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
2011-04-21 15:53:30 +00:00
|
|
|
SoftBody *sb = ob->soft;
|
|
|
|
ListBase *do_effector = NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
do_effector = pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true);
|
2011-04-21 15:53:30 +00:00
|
|
|
_scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
|
|
|
|
pdEndEffectors(&do_effector);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void *exec_scan_for_ext_spring_forces(void *data)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
|
|
|
SB_thread_context *pctx = (SB_thread_context*)data;
|
2009-01-04 14:14:06 +00:00
|
|
|
_scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void sb_sfesf_threads_run(struct Depsgraph *depsgraph, Scene *scene, struct Object *ob, float timenow, int totsprings, int *UNUSED(ptr_to_break_func(void)))
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
2010-06-14 23:56:12 +00:00
|
|
|
ListBase *do_effector = NULL;
|
2008-08-11 20:40:29 +00:00
|
|
|
ListBase threads;
|
|
|
|
SB_thread_context *sb_threads;
|
2012-04-29 15:47:02 +00:00
|
|
|
int i, totthread, left, dec;
|
2008-09-05 23:28:28 +00:00
|
|
|
int lowsprings =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* figure the number of threads while preventing pretty pointless threading overhead */
|
2013-05-08 13:23:17 +00:00
|
|
|
totthread= BKE_scene_num_threads(scene);
|
2008-09-05 23:28:28 +00:00
|
|
|
/* what if we got zillions of CPUs running but less to spread*/
|
|
|
|
while ((totsprings/totthread < lowsprings) && (totthread > 1)) {
|
|
|
|
totthread--;
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBSpringsThread");
|
|
|
|
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
|
|
|
|
left = totsprings;
|
|
|
|
dec = totsprings/totthread +1;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (i=0; i<totthread; i++) {
|
2009-01-04 14:14:06 +00:00
|
|
|
sb_threads[i].scene = scene;
|
2010-06-14 23:56:12 +00:00
|
|
|
sb_threads[i].ob = ob;
|
|
|
|
sb_threads[i].forcetime = 0.0; // not used here
|
|
|
|
sb_threads[i].timenow = timenow;
|
|
|
|
sb_threads[i].ilast = left;
|
2008-08-11 20:40:29 +00:00
|
|
|
left = left - dec;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (left >0) {
|
2008-08-11 20:40:29 +00:00
|
|
|
sb_threads[i].ifirst = left;
|
|
|
|
}
|
|
|
|
else
|
2010-06-14 23:56:12 +00:00
|
|
|
sb_threads[i].ifirst = 0;
|
2010-03-22 09:30:00 +00:00
|
|
|
sb_threads[i].do_effector = do_effector;
|
2014-04-01 11:34:00 +11:00
|
|
|
sb_threads[i].do_deflector = false;// not used here
|
2008-08-11 20:40:29 +00:00
|
|
|
sb_threads[i].fieldfactor = 0.0f;// not used here
|
|
|
|
sb_threads[i].windfactor = 0.0f;// not used here
|
|
|
|
sb_threads[i].nr= i;
|
|
|
|
sb_threads[i].tot= totthread;
|
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totthread > 1) {
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_init(&threads, exec_scan_for_ext_spring_forces, totthread);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (i=0; i<totthread; i++)
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_insert(&threads, &sb_threads[i]);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_end(&threads);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
exec_scan_for_ext_spring_forces(&sb_threads[0]);
|
2010-03-22 09:30:00 +00:00
|
|
|
/* clean up */
|
2008-08-11 20:40:29 +00:00
|
|
|
MEM_freeN(sb_threads);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pdEndEffectors(&do_effector);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* --- the spring external section*/
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static int choose_winner(float*w, float* pos, float*a, float*b, float*c, float*ca, float*cb, float*cc)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
float mindist, cp;
|
2006-11-10 23:09:16 +00:00
|
|
|
int winner =1;
|
2012-07-06 22:48:28 +00:00
|
|
|
mindist = fabsf(dot_v3v3(pos, a));
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-07-06 22:48:28 +00:00
|
|
|
cp = fabsf(dot_v3v3(pos, b));
|
2012-02-27 10:35:39 +00:00
|
|
|
if ( mindist < cp ) {
|
2006-11-10 23:09:16 +00:00
|
|
|
mindist = cp;
|
|
|
|
winner =2;
|
|
|
|
}
|
|
|
|
|
2012-07-06 22:48:28 +00:00
|
|
|
cp = fabsf(dot_v3v3(pos, c));
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mindist < cp ) {
|
2006-11-10 23:09:16 +00:00
|
|
|
mindist = cp;
|
|
|
|
winner =3;
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
switch (winner) {
|
2012-04-29 15:47:02 +00:00
|
|
|
case 1: copy_v3_v3(w, ca); break;
|
|
|
|
case 2: copy_v3_v3(w, cb); break;
|
|
|
|
case 3: copy_v3_v3(w, cc);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
return(winner);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
static int sb_detect_vertex_collisionCached(
|
|
|
|
float opco[3], float facenormal[3], float *damp,
|
|
|
|
float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner,
|
|
|
|
float time, float vel[3], float *intrusion)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
2007-10-29 05:59:26 +00:00
|
|
|
Object *ob= NULL;
|
2006-11-10 23:09:16 +00:00
|
|
|
GHash *hash;
|
|
|
|
GHashIterator *ihash;
|
2015-07-31 14:00:07 +10:00
|
|
|
float nv1[3], nv2[3], nv3[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3] = {0.0, 0.0, 0.0},
|
|
|
|
vv1[3], vv2[3], vv3[3], coledge[3] = {0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f,
|
2011-09-29 15:28:22 +00:00
|
|
|
outerforceaccu[3], innerforceaccu[3],
|
|
|
|
facedist, /* n_mag, */ /* UNUSED */ force_mag_norm, minx, miny, minz, maxx, maxy, maxz,
|
|
|
|
innerfacethickness = -0.5f, outerfacethickness = 0.2f,
|
|
|
|
ee = 5.0f, ff = 0.1f, fa=1;
|
|
|
|
int a, deflected=0, cavel=0, ci=0;
|
2006-11-10 23:09:16 +00:00
|
|
|
/* init */
|
|
|
|
*intrusion = 0.0f;
|
|
|
|
hash = vertexowner->soft->scratch->colliderhash;
|
|
|
|
ihash = BLI_ghashIterator_new(hash);
|
2007-10-18 22:47:55 +00:00
|
|
|
outerforceaccu[0]=outerforceaccu[1]=outerforceaccu[2]=0.0f;
|
|
|
|
innerforceaccu[0]=innerforceaccu[1]=innerforceaccu[2]=0.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
/* go */
|
2013-05-08 12:58:11 +00:00
|
|
|
while (!BLI_ghashIterator_done(ihash)) {
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
ccd_Mesh *ccdm = BLI_ghashIterator_getValue (ihash);
|
|
|
|
ob = BLI_ghashIterator_getKey (ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
{
|
2006-11-10 23:09:16 +00:00
|
|
|
/* only with deflecting set */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->pd && ob->pd->deflect) {
|
2015-07-31 14:00:07 +10:00
|
|
|
const MVert *mvert = NULL;
|
|
|
|
const MVert *mprevvert = NULL;
|
|
|
|
const MVertTri *vt = NULL;
|
|
|
|
const ccdf_minmax *mima = NULL;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ccdm) {
|
2015-07-31 14:00:07 +10:00
|
|
|
mvert = ccdm->mvert;
|
|
|
|
mprevvert = ccdm->mprevvert;
|
|
|
|
vt = ccdm->tri;
|
|
|
|
mima = ccdm->mima;
|
|
|
|
a = ccdm->tri_num;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
minx = ccdm->bbmin[0];
|
|
|
|
miny = ccdm->bbmin[1];
|
|
|
|
minz = ccdm->bbmin[2];
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
maxx = ccdm->bbmax[0];
|
|
|
|
maxy = ccdm->bbmax[1];
|
|
|
|
maxz = ccdm->bbmax[2];
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
if ((opco[0] < minx) ||
|
2012-05-24 16:35:45 +00:00
|
|
|
(opco[1] < miny) ||
|
|
|
|
(opco[2] < minz) ||
|
|
|
|
(opco[0] > maxx) ||
|
|
|
|
(opco[1] > maxy) ||
|
|
|
|
(opco[2] > maxz) )
|
|
|
|
{
|
|
|
|
/* outside the padded boundbox --> collision object is too far away */
|
|
|
|
BLI_ghashIterator_step(ihash);
|
|
|
|
continue;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2006-11-10 23:09:16 +00:00
|
|
|
/*aye that should be cached*/
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("missing cache error\n");
|
2015-05-17 16:47:44 +10:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2010-06-14 23:56:12 +00:00
|
|
|
continue;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* do object level stuff */
|
|
|
|
/* need to have user control for that since it depends on model scale */
|
2012-02-23 02:17:50 +00:00
|
|
|
innerfacethickness = -ob->pd->pdef_sbift;
|
|
|
|
outerfacethickness = ob->pd->pdef_sboft;
|
2006-11-10 23:09:16 +00:00
|
|
|
fa = (ff*outerfacethickness-outerfacethickness);
|
|
|
|
fa *= fa;
|
|
|
|
fa = 1.0f/fa;
|
2010-03-22 09:30:00 +00:00
|
|
|
avel[0]=avel[1]=avel[2]=0.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
/* use mesh*/
|
|
|
|
while (a--) {
|
2015-07-31 14:00:07 +10:00
|
|
|
if ((opco[0] < mima->minx) ||
|
|
|
|
(opco[0] > mima->maxx) ||
|
|
|
|
(opco[1] < mima->miny) ||
|
|
|
|
(opco[1] > mima->maxy) ||
|
|
|
|
(opco[2] < mima->minz) ||
|
|
|
|
(opco[2] > mima->maxz))
|
|
|
|
{
|
|
|
|
mima++;
|
|
|
|
vt++;
|
|
|
|
continue;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mvert) {
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
copy_v3_v3(nv1, mvert[vt->tri[0]].co);
|
|
|
|
copy_v3_v3(nv2, mvert[vt->tri[1]].co);
|
|
|
|
copy_v3_v3(nv3, mvert[vt->tri[2]].co);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mprevvert) {
|
2006-11-10 23:09:16 +00:00
|
|
|
/* grab the average speed of the collider vertices
|
2010-06-14 23:56:12 +00:00
|
|
|
before we spoil nvX
|
2006-11-10 23:09:16 +00:00
|
|
|
humm could be done once a SB steps but then we' need to store that too
|
|
|
|
since the AABB reduced propabitlty to get here drasticallly
|
|
|
|
it might be a nice tradeof CPU <--> memory
|
|
|
|
*/
|
2015-07-31 14:00:07 +10:00
|
|
|
sub_v3_v3v3(vv1, nv1, mprevvert[vt->tri[0]].co);
|
|
|
|
sub_v3_v3v3(vv2, nv2, mprevvert[vt->tri[1]].co);
|
|
|
|
sub_v3_v3v3(vv3, nv3, mprevvert[vt->tri[2]].co);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv1, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv1, mprevvert[vt->tri[0]].co, 1.0f - time);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv2, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv2, mprevvert[vt->tri[1]].co, 1.0f - time);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(nv3, time);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(nv3, mprevvert[vt->tri[2]].co, 1.0f - time);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* switch origin to be nv2*/
|
2011-11-06 16:38:21 +00:00
|
|
|
sub_v3_v3v3(edge1, nv1, nv2);
|
|
|
|
sub_v3_v3v3(edge2, nv3, nv2);
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(dv1, opco, nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
cross_v3_v3v3(d_nvect, edge2, edge1);
|
2011-09-29 15:28:22 +00:00
|
|
|
/* n_mag = */ /* UNUSED */ normalize_v3(d_nvect);
|
2012-04-29 15:47:02 +00:00
|
|
|
facedist = dot_v3v3(dv1, d_nvect);
|
2007-10-18 22:47:55 +00:00
|
|
|
// so rules are
|
|
|
|
//
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)) {
|
|
|
|
if (isect_point_tri_prism_v3(opco, nv1, nv2, nv3) ) {
|
2006-11-10 23:09:16 +00:00
|
|
|
force_mag_norm =(float)exp(-ee*facedist);
|
|
|
|
if (facedist > outerfacethickness*ff)
|
|
|
|
force_mag_norm =(float)force_mag_norm*fa*(facedist - outerfacethickness)*(facedist - outerfacethickness);
|
|
|
|
*damp=ob->pd->pdef_sbdamp;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (facedist > 0.0f) {
|
2006-11-10 23:09:16 +00:00
|
|
|
*damp *= (1.0f - facedist/outerfacethickness);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(outerforceaccu, d_nvect, force_mag_norm);
|
2007-10-18 22:47:55 +00:00
|
|
|
deflected = 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(innerforceaccu, d_nvect, force_mag_norm);
|
2007-10-18 22:47:55 +00:00
|
|
|
if (deflected < 2) deflected = 2;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if ((mprevvert) && (*damp > 0.0f)) {
|
2012-04-29 15:47:02 +00:00
|
|
|
choose_winner(ve, opco, nv1, nv2, nv3, vv1, vv2, vv3);
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(avel, ve);
|
2006-11-10 23:09:16 +00:00
|
|
|
cavel ++;
|
|
|
|
}
|
|
|
|
*intrusion += facedist;
|
|
|
|
ci++;
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2007-10-18 22:47:55 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
mima++;
|
2015-07-31 14:00:07 +10:00
|
|
|
vt++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}/* while a */
|
2012-02-23 02:17:50 +00:00
|
|
|
} /* if (ob->pd && ob->pd->deflect) */
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_step(ihash);
|
2015-05-17 16:47:44 +10:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
} /* while () */
|
2007-10-18 22:47:55 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (deflected == 1) { // no face but 'outer' edge cylinder sees vert
|
2007-10-18 22:47:55 +00:00
|
|
|
force_mag_norm =(float)exp(-ee*mindistedge);
|
|
|
|
if (mindistedge > outerfacethickness*ff)
|
|
|
|
force_mag_norm =(float)force_mag_norm*fa*(mindistedge - outerfacethickness)*(mindistedge - outerfacethickness);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(force, coledge, force_mag_norm);
|
2007-10-18 22:47:55 +00:00
|
|
|
*damp=ob->pd->pdef_sbdamp;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mindistedge > 0.0f) {
|
2007-10-18 22:47:55 +00:00
|
|
|
*damp *= (1.0f - mindistedge/outerfacethickness);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (deflected == 2) { // face inner detected
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(force, innerforceaccu);
|
2007-10-18 22:47:55 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (deflected == 3) { // face outer detected
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(force, outerforceaccu);
|
2007-10-18 22:47:55 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
BLI_ghashIterator_free(ihash);
|
2012-04-29 15:47:02 +00:00
|
|
|
if (cavel) mul_v3_fl(avel, 1.0f/(float)cavel);
|
|
|
|
copy_v3_v3(vel, avel);
|
2006-11-10 23:09:16 +00:00
|
|
|
if (ci) *intrusion /= ci;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (deflected) {
|
2010-08-15 15:14:08 +00:00
|
|
|
normalize_v3_v3(facenormal, force);
|
2006-10-10 21:49:02 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
return deflected;
|
2006-10-10 21:49:02 +00:00
|
|
|
}
|
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* sandbox to plug in various deflection algos */
|
2012-04-29 15:47:02 +00:00
|
|
|
static int sb_deflect_face(Object *ob, float *actpos, float *facenormal, float *force, float *cf, float time, float *vel, float *intrusion)
|
2005-04-12 21:36:21 +00:00
|
|
|
{
|
2006-10-10 21:49:02 +00:00
|
|
|
float s_actpos[3];
|
2010-06-14 23:56:12 +00:00
|
|
|
int deflected;
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(s_actpos, actpos);
|
|
|
|
deflected= sb_detect_vertex_collisionCached(s_actpos, facenormal, cf, force, ob->lay, ob, time, vel, intrusion);
|
|
|
|
//deflected= sb_detect_vertex_collisionCachedEx(s_actpos, facenormal, cf, force, ob->lay, ob, time, vel, intrusion);
|
2005-04-12 21:36:21 +00:00
|
|
|
return(deflected);
|
|
|
|
}
|
|
|
|
|
2008-02-16 00:07:05 +00:00
|
|
|
/* hiding this for now .. but the jacobian may pop up on other tasks .. so i'd like to keep it
|
2012-04-29 15:47:02 +00:00
|
|
|
static void dfdx_spring(int ia, int ic, int op, float dir[3], float L, float len, float factor)
|
2010-06-14 23:56:12 +00:00
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
float m, delta_ij;
|
|
|
|
int i, j;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (L < len) {
|
2017-05-19 22:18:54 +10:00
|
|
|
for (i=0;i<3;i++) {
|
2012-02-27 10:35:39 +00:00
|
|
|
for (j=0;j<3;j++) {
|
2008-01-09 00:25:51 +00:00
|
|
|
delta_ij = (i==j ? (1.0f): (0.0f));
|
|
|
|
m=factor*(dir[i]*dir[j] + (1-L/len)*(delta_ij - dir[i]*dir[j]));
|
2015-11-24 20:42:10 +01:00
|
|
|
EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2017-05-19 22:18:54 +10:00
|
|
|
}
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2017-05-19 22:18:54 +10:00
|
|
|
for (i=0;i<3;i++) {
|
2012-02-27 10:35:39 +00:00
|
|
|
for (j=0;j<3;j++) {
|
2008-01-09 00:25:51 +00:00
|
|
|
m=factor*dir[i]*dir[j];
|
2015-11-24 20:42:10 +01:00
|
|
|
EIG_linear_solver_matrix_add(ia+i, op+ic+j, m);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2017-05-19 22:18:54 +10:00
|
|
|
}
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-12 21:36:21 +00:00
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
|
|
|
|
static void dfdx_goal(int ia, int ic, int op, float factor)
|
2010-06-14 23:56:12 +00:00
|
|
|
{
|
2008-01-09 00:25:51 +00:00
|
|
|
int i;
|
2015-11-24 20:42:10 +01:00
|
|
|
for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, op+ic+i, factor);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void dfdv_goal(int ia, int ic, float factor)
|
2010-06-14 23:56:12 +00:00
|
|
|
{
|
2008-01-09 00:25:51 +00:00
|
|
|
int i;
|
2015-11-24 20:42:10 +01:00
|
|
|
for (i=0;i<3;i++) EIG_linear_solver_matrix_add(ia+i, ic+i, factor);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
*/
|
2015-11-22 21:12:20 +01:00
|
|
|
static void sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float UNUSED(forcetime))
|
2006-01-31 22:48:41 +00:00
|
|
|
{
|
2008-01-09 00:25:51 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2012-04-29 15:47:02 +00:00
|
|
|
BodyPoint *bp1, *bp2;
|
2008-01-09 00:25:51 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
float dir[3], dvel[3];
|
|
|
|
float distance, forcefactor, kd, absvel, projvel, kw;
|
2011-05-22 16:29:51 +00:00
|
|
|
#if 0 /* UNUSED */
|
2012-04-29 15:47:02 +00:00
|
|
|
int ia, ic;
|
2011-05-22 16:29:51 +00:00
|
|
|
#endif
|
2008-01-09 00:25:51 +00:00
|
|
|
/* prepare depending on which side of the spring we are on */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bpi == bs->v1) {
|
2008-01-09 00:25:51 +00:00
|
|
|
bp1 = &sb->bpoint[bs->v1];
|
|
|
|
bp2 = &sb->bpoint[bs->v2];
|
2011-05-22 16:29:51 +00:00
|
|
|
#if 0 /* UNUSED */
|
2008-01-09 00:25:51 +00:00
|
|
|
ia =3*bs->v1;
|
|
|
|
ic =3*bs->v2;
|
2011-05-22 16:29:51 +00:00
|
|
|
#endif
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
else if (bpi == bs->v2) {
|
2008-01-09 00:25:51 +00:00
|
|
|
bp1 = &sb->bpoint[bs->v2];
|
|
|
|
bp2 = &sb->bpoint[bs->v1];
|
2011-05-22 16:29:51 +00:00
|
|
|
#if 0 /* UNUSED */
|
2008-01-09 00:25:51 +00:00
|
|
|
ia =3*bs->v2;
|
|
|
|
ic =3*bs->v1;
|
2011-05-22 16:29:51 +00:00
|
|
|
#endif
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2008-01-09 00:25:51 +00:00
|
|
|
/* TODO make this debug option */
|
|
|
|
/**/
|
|
|
|
printf("bodypoint <bpi> is not attached to spring <*bs> --> sb_spring_force()\n");
|
|
|
|
return;
|
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
/* do bp1 <--> bp2 elastic */
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(dir, bp1->pos, bp2->pos);
|
2009-11-10 20:43:45 +00:00
|
|
|
distance = normalize_v3(dir);
|
2008-01-09 00:25:51 +00:00
|
|
|
if (bs->len < distance)
|
|
|
|
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
|
|
|
|
else
|
|
|
|
iks = 1.0f/(1.0f-sb->inpush)-1.0f ;/* inner spring constants function */
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (bs->len > 0.0f) /* check for degenerated springs */
|
2008-01-09 00:25:51 +00:00
|
|
|
forcefactor = iks/bs->len;
|
|
|
|
else
|
|
|
|
forcefactor = iks;
|
2009-11-04 00:21:25 +00:00
|
|
|
kw = (bp1->springweight+bp2->springweight)/2.0f;
|
|
|
|
kw = kw * kw;
|
|
|
|
kw = kw * kw;
|
2012-02-27 10:35:39 +00:00
|
|
|
switch (bs->springtype) {
|
2009-11-04 00:21:25 +00:00
|
|
|
case SB_EDGE:
|
2010-06-15 09:47:37 +00:00
|
|
|
case SB_HANDLE:
|
2010-06-14 23:56:12 +00:00
|
|
|
forcefactor *= kw;
|
2009-11-04 00:21:25 +00:00
|
|
|
break;
|
|
|
|
case SB_BEND:
|
2010-06-14 23:56:12 +00:00
|
|
|
forcefactor *=sb->secondspring*kw;
|
2009-11-04 00:21:25 +00:00
|
|
|
break;
|
|
|
|
case SB_STIFFQUAD:
|
2010-06-14 23:56:12 +00:00
|
|
|
forcefactor *=sb->shearstiff*sb->shearstiff* kw;
|
2009-11-04 00:21:25 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp1->force, dir, (bs->len - distance) * forcefactor);
|
2008-01-09 00:25:51 +00:00
|
|
|
|
|
|
|
/* do bp1 <--> bp2 viscous */
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(dvel, bp1->vec, bp2->vec);
|
2008-01-09 00:25:51 +00:00
|
|
|
kd = sb->infrict * sb_fric_force_scale(ob);
|
2009-11-10 20:43:45 +00:00
|
|
|
absvel = normalize_v3(dvel);
|
2012-04-29 15:47:02 +00:00
|
|
|
projvel = dot_v3v3(dir, dvel);
|
2008-01-09 00:25:51 +00:00
|
|
|
kd *= absvel * projvel;
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp1->force, dir, -kd);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2006-10-11 22:53:22 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* since this is definitely the most CPU consuming task here .. try to spread it */
|
|
|
|
/* core function _softbody_calc_forces_slice_in_a_thread */
|
|
|
|
/* result is int to be able to flag user break */
|
2012-04-29 15:47:02 +00:00
|
|
|
static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow, int ifirst, int ilast, int *UNUSED(ptr_to_break_func(void)), ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2008-08-11 20:40:29 +00:00
|
|
|
float iks;
|
2012-04-29 15:47:02 +00:00
|
|
|
int bb, do_selfcollision, do_springcollision, do_aero;
|
2008-08-11 20:40:29 +00:00
|
|
|
int number_of_points_here = ilast - ifirst;
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2005-01-12 22:28:13 +00:00
|
|
|
BodyPoint *bp;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* intitialize */
|
|
|
|
if (sb) {
|
2018-04-16 17:08:27 +02:00
|
|
|
/* check conditions for various options */
|
|
|
|
/* +++ could be done on object level to squeeze out the last bits of it */
|
|
|
|
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
|
|
|
|
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
|
|
|
|
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
|
|
|
|
/* --- could be done on object level to squeeze out the last bits of it */
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-31 00:59:17 +00:00
|
|
|
printf("Error expected a SB here\n");
|
2008-08-11 20:40:29 +00:00
|
|
|
return (999);
|
|
|
|
}
|
2006-10-11 22:53:22 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* debugerin */
|
2012-04-21 12:51:47 +00:00
|
|
|
if (sb->totpoint < ifirst) {
|
2008-08-11 20:40:29 +00:00
|
|
|
printf("Aye 998");
|
|
|
|
return (998);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
/* debugerin */
|
2006-10-11 22:53:22 +00:00
|
|
|
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
bp = &sb->bpoint[ifirst];
|
2012-02-23 02:17:50 +00:00
|
|
|
for (bb=number_of_points_here; bb>0; bb--, bp++) {
|
2006-11-10 23:09:16 +00:00
|
|
|
/* clear forces accumulator */
|
2012-10-22 08:15:51 +00:00
|
|
|
bp->force[0] = bp->force[1] = bp->force[2] = 0.0;
|
2006-10-03 12:12:24 +00:00
|
|
|
/* naive ball self collision */
|
|
|
|
/* needs to be done if goal snaps or not */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (do_selfcollision) {
|
2011-04-21 15:53:30 +00:00
|
|
|
int attached;
|
|
|
|
BodyPoint *obp;
|
|
|
|
BodySpring *bs;
|
2012-04-29 15:47:02 +00:00
|
|
|
int c, b;
|
|
|
|
float velcenter[3], dvel[3], def[3];
|
2011-04-21 15:53:30 +00:00
|
|
|
float distance;
|
|
|
|
float compare;
|
|
|
|
float bstune = sb->ballstiff;
|
|
|
|
|
2018-01-10 01:51:04 +01:00
|
|
|
/* running in a slice we must not assume anything done with obp neither alter the data of obp */
|
|
|
|
for (c=sb->totpoint, obp= sb->bpoint; c>0; c--, obp++) {
|
2011-04-21 15:53:30 +00:00
|
|
|
compare = (obp->colball + bp->colball);
|
|
|
|
sub_v3_v3v3(def, bp->pos, obp->pos);
|
|
|
|
/* rather check the AABBoxes before ever calulating the real distance */
|
2015-09-14 02:21:15 +10:00
|
|
|
/* mathematically it is completely nuts, but performance is pretty much (3) times faster */
|
2011-04-21 15:53:30 +00:00
|
|
|
if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue;
|
|
|
|
distance = normalize_v3(def);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (distance < compare ) {
|
2011-04-21 15:53:30 +00:00
|
|
|
/* exclude body points attached with a spring */
|
|
|
|
attached = 0;
|
2012-02-27 10:35:39 +00:00
|
|
|
for (b=obp->nofsprings;b>0;b--) {
|
2011-04-21 15:53:30 +00:00
|
|
|
bs = sb->bspring + obp->springs[b-1];
|
2012-05-20 19:49:27 +00:00
|
|
|
if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)) {
|
2011-04-21 15:53:30 +00:00
|
|
|
attached=1;
|
|
|
|
continue;}
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (!attached) {
|
|
|
|
float f = bstune / (distance) + bstune / (compare * compare) * distance - 2.0f * bstune / compare;
|
2006-10-13 21:27:43 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
mid_v3_v3v3(velcenter, bp->vec, obp->vec);
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(dvel, velcenter, bp->vec);
|
|
|
|
mul_v3_fl(dvel, _final_mass(ob, bp));
|
2006-10-13 21:27:43 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, def, f * (1.0f - sb->balldamp));
|
|
|
|
madd_v3_v3fl(bp->force, dvel, sb->balldamp);
|
2006-10-03 12:12:24 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-21 15:53:30 +00:00
|
|
|
}
|
2006-10-14 19:03:06 +00:00
|
|
|
}
|
|
|
|
/* naive ball self collision done */
|
2006-10-03 12:12:24 +00:00
|
|
|
|
2014-09-29 15:51:47 +10:00
|
|
|
if (_final_goal(ob, bp) < SOFTGOALSNAP) { /* omit this bp when it snaps */
|
2010-06-14 23:56:12 +00:00
|
|
|
float auxvect[3];
|
2005-01-12 22:28:13 +00:00
|
|
|
float velgoal[3];
|
2008-02-08 15:36:39 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/* do goal stuff */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->softflag & OB_SB_GOAL) {
|
2005-04-02 13:57:23 +00:00
|
|
|
/* true elastic goal */
|
2012-04-29 15:47:02 +00:00
|
|
|
float ks, kd;
|
|
|
|
sub_v3_v3v3(auxvect, bp->pos, bp->origT);
|
2012-02-27 10:35:39 +00:00
|
|
|
ks = 1.0f / (1.0f - _final_goal(ob, bp) * sb->goalspring) - 1.0f;
|
2008-01-09 00:25:51 +00:00
|
|
|
bp->force[0]+= -ks*(auxvect[0]);
|
|
|
|
bp->force[1]+= -ks*(auxvect[1]);
|
|
|
|
bp->force[2]+= -ks*(auxvect[2]);
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* calulate damping forces generated by goals*/
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(velgoal, bp->origS, bp->origE);
|
2012-02-27 10:35:39 +00:00
|
|
|
kd = sb->goalfrict * sb_fric_force_scale(ob);
|
2012-04-29 15:47:02 +00:00
|
|
|
add_v3_v3v3(auxvect, velgoal, bp->vec);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-11-11 12:00:08 +00:00
|
|
|
if (forcetime > 0.0f) { /* make sure friction does not become rocket motor on time reversal */
|
2008-01-09 00:25:51 +00:00
|
|
|
bp->force[0]-= kd * (auxvect[0]);
|
|
|
|
bp->force[1]-= kd * (auxvect[1]);
|
|
|
|
bp->force[2]-= kd * (auxvect[2]);
|
2005-04-02 13:57:23 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
bp->force[0]-= kd * (velgoal[0] - bp->vec[0]);
|
|
|
|
bp->force[1]-= kd * (velgoal[1] - bp->vec[1]);
|
|
|
|
bp->force[2]-= kd * (velgoal[2] - bp->vec[2]);
|
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
/* done goal stuff */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/* gravitation */
|
2012-09-11 02:18:27 +00:00
|
|
|
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
float gravity[3];
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(gravity, scene->physics_settings.gravity);
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(gravity, sb_grav_force_scale(ob)*_final_mass(ob, bp)*sb->effector_weights->global_gravity); /* individual mass of node here */
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(bp->force, gravity);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-05 20:28:32 +00:00
|
|
|
/* particle field & vortex */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (do_effector) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
EffectedPoint epoint;
|
2008-08-11 20:40:29 +00:00
|
|
|
float kd;
|
2012-10-22 08:15:51 +00:00
|
|
|
float force[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
float speed[3] = {0.0f, 0.0f, 0.0f};
|
2005-11-19 21:35:06 +00:00
|
|
|
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint);
|
|
|
|
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-21 18:58:15 +00:00
|
|
|
/* apply forcefield*/
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale);
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(bp->force, force);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
/* BP friction in moving media */
|
|
|
|
kd= sb->mediafrict* eval_sb_fric_force_scale;
|
2005-04-21 18:58:15 +00:00
|
|
|
bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale);
|
|
|
|
bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale);
|
|
|
|
bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale);
|
2005-04-05 20:28:32 +00:00
|
|
|
/* now we'll have nice centrifugal effect for vortex */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-05 20:28:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2006-10-14 19:03:06 +00:00
|
|
|
/* BP friction in media (not) moving*/
|
2010-06-14 23:56:12 +00:00
|
|
|
float kd = sb->mediafrict* sb_fric_force_scale(ob);
|
2005-04-05 20:28:32 +00:00
|
|
|
/* assume it to be proportional to actual velocity */
|
|
|
|
bp->force[0]-= bp->vec[0]*kd;
|
|
|
|
bp->force[1]-= bp->vec[1]*kd;
|
|
|
|
bp->force[2]-= bp->vec[2]*kd;
|
|
|
|
/* friction in media done */
|
2005-04-04 18:09:47 +00:00
|
|
|
}
|
2006-10-14 19:03:06 +00:00
|
|
|
/* +++cached collision targets */
|
2006-11-10 23:09:16 +00:00
|
|
|
bp->choke = 0.0f;
|
2008-01-31 23:00:08 +00:00
|
|
|
bp->choke2 = 0.0f;
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->loc_flag &= ~SBF_DOFUZZY;
|
2012-02-23 02:17:50 +00:00
|
|
|
if (do_deflector && !(bp->loc_flag & SBF_OUTOFCOLLISION) ) {
|
2012-04-29 15:47:02 +00:00
|
|
|
float cfforce[3], defforce[3] ={0.0f, 0.0f, 0.0f}, vel[3] = {0.0f, 0.0f, 0.0f}, facenormal[3], cf = 1.0f, intrusion;
|
2008-08-11 20:40:29 +00:00
|
|
|
float kd = 1.0f;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (sb_deflect_face(ob, bp->pos, facenormal, defforce, &cf, timenow, vel, &intrusion)) {
|
2015-05-17 16:47:44 +10:00
|
|
|
if (intrusion < 0.0f) {
|
|
|
|
sb->scratch->flag |= SBF_DOFUZZY;
|
|
|
|
bp->loc_flag |= SBF_DOFUZZY;
|
|
|
|
bp->choke = sb->choke*0.01f;
|
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2015-05-17 16:47:44 +10:00
|
|
|
sub_v3_v3v3(cfforce, bp->vec, vel);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, cfforce, -cf * 50.0f);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, defforce, kd);
|
2005-04-04 18:09:47 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2006-09-28 20:27:46 +00:00
|
|
|
}
|
2006-10-14 19:03:06 +00:00
|
|
|
/* ---cached collision targets */
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2006-10-14 19:03:06 +00:00
|
|
|
/* +++springs */
|
2008-08-11 20:40:29 +00:00
|
|
|
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->bspring) { /* spring list exists at all ? */
|
2008-08-11 20:40:29 +00:00
|
|
|
int b;
|
2010-06-14 23:56:12 +00:00
|
|
|
BodySpring *bs;
|
2012-02-27 10:35:39 +00:00
|
|
|
for (b=bp->nofsprings;b>0;b--) {
|
2005-04-18 21:51:45 +00:00
|
|
|
bs = sb->bspring + bp->springs[b-1];
|
2012-02-27 10:35:39 +00:00
|
|
|
if (do_springcollision || do_aero) {
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(bp->force, bs->ext_force);
|
2006-10-10 21:49:02 +00:00
|
|
|
if (bs->flag & BSF_INTERSECT)
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->choke = bs->cf;
|
2006-10-10 21:49:02 +00:00
|
|
|
|
|
|
|
}
|
2015-11-22 21:12:20 +01:00
|
|
|
// sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime)
|
|
|
|
sb_spring_force(ob, ilast-bb, bs, iks, forcetime);
|
2005-04-18 21:51:45 +00:00
|
|
|
}/* loop springs */
|
2010-06-14 23:56:12 +00:00
|
|
|
}/* existing spring list */
|
2005-04-18 21:51:45 +00:00
|
|
|
}/*any edges*/
|
2006-10-14 19:03:06 +00:00
|
|
|
/* ---springs */
|
2005-04-18 21:51:45 +00:00
|
|
|
}/*omit on snap */
|
|
|
|
}/*loop all bp's*/
|
2011-11-15 16:38:48 +00:00
|
|
|
return 0; /*done fine*/
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void *exec_softbody_calc_forces(void *data)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
|
|
|
SB_thread_context *pctx = (SB_thread_context*)data;
|
2012-04-29 15:47:02 +00:00
|
|
|
_softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector, pctx->do_deflector, pctx->fieldfactor, pctx->windfactor);
|
2011-02-13 10:52:18 +00:00
|
|
|
return NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow, int totpoint, int *UNUSED(ptr_to_break_func(void)), struct ListBase *do_effector, int do_deflector, float fieldfactor, float windfactor)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
|
|
|
ListBase threads;
|
|
|
|
SB_thread_context *sb_threads;
|
2012-04-29 15:47:02 +00:00
|
|
|
int i, totthread, left, dec;
|
2008-09-05 23:28:28 +00:00
|
|
|
int lowpoints =100; /* wild guess .. may increase with better thread management 'above' or even be UI option sb->spawn_cf_threads_nopts */
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* figure the number of threads while preventing pretty pointless threading overhead */
|
2013-05-08 13:23:17 +00:00
|
|
|
totthread= BKE_scene_num_threads(scene);
|
2008-09-05 23:28:28 +00:00
|
|
|
/* what if we got zillions of CPUs running but less to spread*/
|
|
|
|
while ((totpoint/totthread < lowpoints) && (totthread > 1)) {
|
|
|
|
totthread--;
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
2008-09-05 23:28:28 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
/* printf("sb_cf_threads_run spawning %d threads\n", totthread); */
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
sb_threads= MEM_callocN(sizeof(SB_thread_context)*totthread, "SBThread");
|
|
|
|
memset(sb_threads, 0, sizeof(SB_thread_context)*totthread);
|
|
|
|
left = totpoint;
|
|
|
|
dec = totpoint/totthread +1;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (i=0; i<totthread; i++) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
sb_threads[i].scene = scene;
|
2010-06-14 23:56:12 +00:00
|
|
|
sb_threads[i].ob = ob;
|
|
|
|
sb_threads[i].forcetime = forcetime;
|
|
|
|
sb_threads[i].timenow = timenow;
|
|
|
|
sb_threads[i].ilast = left;
|
2008-08-11 20:40:29 +00:00
|
|
|
left = left - dec;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (left >0) {
|
2008-08-11 20:40:29 +00:00
|
|
|
sb_threads[i].ifirst = left;
|
|
|
|
}
|
|
|
|
else
|
2010-06-14 23:56:12 +00:00
|
|
|
sb_threads[i].ifirst = 0;
|
2010-03-22 09:30:00 +00:00
|
|
|
sb_threads[i].do_effector = do_effector;
|
|
|
|
sb_threads[i].do_deflector = do_deflector;
|
2008-08-11 20:40:29 +00:00
|
|
|
sb_threads[i].fieldfactor = fieldfactor;
|
|
|
|
sb_threads[i].windfactor = windfactor;
|
|
|
|
sb_threads[i].nr= i;
|
|
|
|
sb_threads[i].tot= totthread;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totthread > 1) {
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_init(&threads, exec_softbody_calc_forces, totthread);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (i=0; i<totthread; i++)
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_insert(&threads, &sb_threads[i]);
|
The long awaited Particle patch from Janne Karhu
http://www.blender3d.org/cms/New_Particle_options_a.721.0.html
There's no doubt this patch had a lot of good ideas for features, and I
want to compliment Janne again for getting it all to work even!
A more careful review of the features and code did show however quite some
flaws and bugs... partially because the current particle code was very much
polluted already, but also because of the implementation lacked quality.
However, the patch was too good to reject, so I've fixed and recoded the
parts that needed it most. :)
Here's a list of of most evident changes in the patch;
- Guides support recoded. It was implemented as a true 'force field',
checking all Curve path points for each particle to find the closest. Was
just far too slow, and didn't support looping or bends well.
The new implementation is fast (real time) and treats the paths as actual
trajectory for the particle.
- Guides didn't integrate in the physics/speed system either, was added as
exception. Now it's integrated and can be combined with other velocities
or forces
- Use of Fields was slow code in general, made it use a Cache instead.
- The "even" distribution didn't work for Jittered sample patterns.
- The "even" or "vertexgroup" code in the main loops were badly constructed,
giving too much cpu for a simple task. Instead of going over all faces
many times, it now only does it once.
Same part of the code used a lot of temporal unneeded mallocs.
- Use of DerivedMesh or Mesh was confused, didn't work for Subsurfs in all
cases
- Support for vertex groups was slow, evaluating vertexgroups too often
- When a vertexgroup failed to read, it was wrongly handled (set to zero).
VertexGroup support now is with a name.
- Split up the too huge build_particle() call in some parts (moving new code)
- The "texture re-timing" option failed for moving Objects. The old code used
the convention that particles were added with increasing time steps.
Solved by creating a object Matrix Cache.
Also: the texture coordinates had to be corrected to become "OrCo".
- The "Disp" option only was used to draw less particles. Changed it to
actually calculate fewer particles for 3D viewing, but render all still.
So now it can be used to keep editing realtime.
Removed;
The "speed threshold" and "Tight" features were not copied over. This
resembled too much to feature overkill. Needs re-evaluation.
Also the "Deform" option was not added, I prefer to first check if the
current particle system really works for the Modifier system.
And:
- Added integration for particle force fields in the dependency graph
- Added TAB completion for vertexgroup names!
- Made the 'wait cursor' only appear when particles take more than 0.5 sec
- The particle jitter table order now is randomized too, giving much
nicer emitting of particles in large faces.
- Vortex field didn't correctly use speed/forces, so it didn't work for
collisions.
- Triangle distribution was wrong
- Removed ancient bug that applied in a *very* weird way speed and forces.
(location changes got the half force, speed the full...???)
So much... might have forgotten some notes! :)
2005-11-10 16:01:56 +00:00
|
|
|
|
2018-02-16 01:13:46 +11:00
|
|
|
BLI_threadpool_end(&threads);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
exec_softbody_calc_forces(&sb_threads[0]);
|
2010-03-22 09:30:00 +00:00
|
|
|
/* clean up */
|
2008-08-11 20:40:29 +00:00
|
|
|
MEM_freeN(sb_threads);
|
|
|
|
}
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void softbody_calc_forcesEx(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float forcetime, float timenow)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
2017-06-12 13:35:00 +10:00
|
|
|
/* rule we never alter free variables :bp->vec bp->pos in here !
|
|
|
|
* this will ruin adaptive stepsize AKA heun! (BM)
|
|
|
|
*/
|
2008-08-11 20:40:29 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2011-05-22 16:29:51 +00:00
|
|
|
/*BodyPoint *bproot;*/ /* UNUSED */
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
ListBase *do_effector = NULL;
|
2011-05-22 16:29:51 +00:00
|
|
|
/* float gravity; */ /* UNUSED */
|
2011-01-09 01:17:56 +00:00
|
|
|
/* float iks; */
|
2010-06-14 23:56:12 +00:00
|
|
|
float fieldfactor = -1.0f, windfactor = 0.25;
|
2012-04-29 15:47:02 +00:00
|
|
|
int do_deflector /*, do_selfcollision*/, do_springcollision, do_aero;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-05-22 16:29:51 +00:00
|
|
|
/* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* check conditions for various options */
|
2018-06-08 19:26:46 +02:00
|
|
|
do_deflector= query_external_colliders(depsgraph, sb->collision_group);
|
2011-05-22 16:29:51 +00:00
|
|
|
/* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
|
2008-08-11 20:40:29 +00:00
|
|
|
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
|
|
|
|
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-01-09 01:17:56 +00:00
|
|
|
/* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */
|
2011-05-22 16:29:51 +00:00
|
|
|
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
if (do_springcollision || do_aero)
|
2018-04-06 12:07:27 +02:00
|
|
|
sb_sfesf_threads_run(depsgraph, scene, ob, timenow, sb->totspring, NULL);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* after spring scan because it uses Effoctors too */
|
2018-04-06 12:07:27 +02:00
|
|
|
do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, sb->effector_weights, true);
|
The long awaited Particle patch from Janne Karhu
http://www.blender3d.org/cms/New_Particle_options_a.721.0.html
There's no doubt this patch had a lot of good ideas for features, and I
want to compliment Janne again for getting it all to work even!
A more careful review of the features and code did show however quite some
flaws and bugs... partially because the current particle code was very much
polluted already, but also because of the implementation lacked quality.
However, the patch was too good to reject, so I've fixed and recoded the
parts that needed it most. :)
Here's a list of of most evident changes in the patch;
- Guides support recoded. It was implemented as a true 'force field',
checking all Curve path points for each particle to find the closest. Was
just far too slow, and didn't support looping or bends well.
The new implementation is fast (real time) and treats the paths as actual
trajectory for the particle.
- Guides didn't integrate in the physics/speed system either, was added as
exception. Now it's integrated and can be combined with other velocities
or forces
- Use of Fields was slow code in general, made it use a Cache instead.
- The "even" distribution didn't work for Jittered sample patterns.
- The "even" or "vertexgroup" code in the main loops were badly constructed,
giving too much cpu for a simple task. Instead of going over all faces
many times, it now only does it once.
Same part of the code used a lot of temporal unneeded mallocs.
- Use of DerivedMesh or Mesh was confused, didn't work for Subsurfs in all
cases
- Support for vertex groups was slow, evaluating vertexgroups too often
- When a vertexgroup failed to read, it was wrongly handled (set to zero).
VertexGroup support now is with a name.
- Split up the too huge build_particle() call in some parts (moving new code)
- The "texture re-timing" option failed for moving Objects. The old code used
the convention that particles were added with increasing time steps.
Solved by creating a object Matrix Cache.
Also: the texture coordinates had to be corrected to become "OrCo".
- The "Disp" option only was used to draw less particles. Changed it to
actually calculate fewer particles for 3D viewing, but render all still.
So now it can be used to keep editing realtime.
Removed;
The "speed threshold" and "Tight" features were not copied over. This
resembled too much to feature overkill. Needs re-evaluation.
Also the "Deform" option was not added, I prefer to first check if the
current particle system really works for the Modifier system.
And:
- Added integration for particle force fields in the dependency graph
- Added TAB completion for vertexgroup names!
- Made the 'wait cursor' only appear when particles take more than 0.5 sec
- The particle jitter table order now is randomized too, giving much
nicer emitting of particles in large faces.
- Vortex field didn't correctly use speed/forces, so it didn't work for
collisions.
- Triangle distribution was wrong
- Removed ancient bug that applied in a *very* weird way speed and forces.
(location changes got the half force, speed the full...???)
So much... might have forgotten some notes! :)
2005-11-10 16:01:56 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
if (do_deflector) {
|
|
|
|
float defforce[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
do_deflector = sb_detect_aabb_collisionCached(defforce, ob->lay, ob, timenow);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
sb_cf_threads_run(scene, ob, forcetime, timenow, sb->totpoint, NULL, do_effector, do_deflector, fieldfactor, windfactor);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
|
|
|
/* finally add forces caused by face collision */
|
2012-04-29 15:47:02 +00:00
|
|
|
if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
/* finish matrix and solve */
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pdEndEffectors(&do_effector);
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void softbody_calc_forces(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float forcetime, float timenow)
|
2008-08-11 20:40:29 +00:00
|
|
|
{
|
|
|
|
/* redirection to the new threaded Version */
|
2012-08-08 18:21:54 +00:00
|
|
|
if (!(G.debug_value & 0x10)) { // 16
|
2018-04-06 12:07:27 +02:00
|
|
|
softbody_calc_forcesEx(depsgraph, scene, ob, forcetime, timenow);
|
2008-08-11 20:40:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2008-08-11 20:40:29 +00:00
|
|
|
/* so the following will die */
|
|
|
|
/* |||||||||||||||||||||||||| */
|
|
|
|
/* VVVVVVVVVVVVVVVVVVVVVVVVVV */
|
2008-09-05 23:28:28 +00:00
|
|
|
/*backward compatibility note:
|
2010-06-14 23:56:12 +00:00
|
|
|
fixing bug [17428] which forces adaptive step size to tiny steps
|
|
|
|
in some situations
|
2012-08-08 18:21:54 +00:00
|
|
|
.. keeping G.debug_value==17 0x11 option for old files 'needing' the bug*/
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
/* rule we never alter free variables :bp->vec bp->pos in here !
|
2016-07-02 10:02:04 +10:00
|
|
|
* this will ruin adaptive stepsize AKA heun! (BM)
|
2008-08-11 20:40:29 +00:00
|
|
|
*/
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
|
|
|
BodyPoint *bp;
|
2011-05-22 16:29:51 +00:00
|
|
|
/* BodyPoint *bproot; */ /* UNUSED */
|
2010-06-14 23:56:12 +00:00
|
|
|
BodySpring *bs;
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
ListBase *do_effector = NULL;
|
2012-04-29 15:47:02 +00:00
|
|
|
float iks, ks, kd, gravity[3] = {0.0f, 0.0f, 0.0f};
|
2010-06-14 23:56:12 +00:00
|
|
|
float fieldfactor = -1.0f, windfactor = 0.25f;
|
2008-08-11 20:40:29 +00:00
|
|
|
float tune = sb->ballstiff;
|
2015-11-23 11:27:02 +11:00
|
|
|
int do_deflector, do_selfcollision, do_springcollision, do_aero;
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(gravity, scene->physics_settings.gravity);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(gravity, sb_grav_force_scale(ob)*sb->effector_weights->global_gravity);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* check conditions for various options */
|
2018-06-08 19:26:46 +02:00
|
|
|
do_deflector= query_external_colliders(depsgraph, sb->collision_group);
|
2008-08-11 20:40:29 +00:00
|
|
|
do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
|
|
|
|
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
|
|
|
|
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
|
|
|
|
|
|
|
|
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
|
2011-05-22 16:29:51 +00:00
|
|
|
/* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
|
2008-01-09 00:25:51 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
if (do_springcollision || do_aero) scan_for_ext_spring_forces(depsgraph, scene, ob, timenow);
|
2008-08-11 20:40:29 +00:00
|
|
|
/* after spring scan because it uses Effoctors too */
|
2018-04-06 12:07:27 +02:00
|
|
|
do_effector= pdInitEffectors(depsgraph, scene, ob, NULL, ob->soft->effector_weights, true);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
if (do_deflector) {
|
|
|
|
float defforce[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
do_deflector = sb_detect_aabb_collisionCached(defforce, ob->lay, ob, timenow);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
|
|
|
|
2015-11-23 11:27:02 +11:00
|
|
|
bp = sb->bpoint;
|
|
|
|
for (int a = sb->totpoint; a > 0; a--, bp++) {
|
2008-08-11 20:40:29 +00:00
|
|
|
/* clear forces accumulator */
|
2012-10-22 08:15:51 +00:00
|
|
|
bp->force[0] = bp->force[1] = bp->force[2] = 0.0;
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* naive ball self collision */
|
|
|
|
/* needs to be done if goal snaps or not */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (do_selfcollision) {
|
2008-08-11 20:40:29 +00:00
|
|
|
int attached;
|
|
|
|
BodyPoint *obp;
|
2012-04-29 15:47:02 +00:00
|
|
|
int c, b;
|
|
|
|
float velcenter[3], dvel[3], def[3];
|
2008-08-11 20:40:29 +00:00
|
|
|
float distance;
|
|
|
|
float compare;
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (c=sb->totpoint, obp= sb->bpoint; c>=a; c--, obp++) {
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
//if ((bp->octantflag & obp->octantflag) == 0) continue;
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
compare = (obp->colball + bp->colball);
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(def, bp->pos, obp->pos);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* rather check the AABBoxes before ever calulating the real distance */
|
2015-09-14 02:21:15 +10:00
|
|
|
/* mathematically it is completely nuts, but performance is pretty much (3) times faster */
|
2008-08-11 20:40:29 +00:00
|
|
|
if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue;
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
distance = normalize_v3(def);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (distance < compare ) {
|
2008-08-11 20:40:29 +00:00
|
|
|
/* exclude body points attached with a spring */
|
|
|
|
attached = 0;
|
2012-02-27 10:35:39 +00:00
|
|
|
for (b=obp->nofsprings;b>0;b--) {
|
2008-08-11 20:40:29 +00:00
|
|
|
bs = sb->bspring + obp->springs[b-1];
|
2012-05-20 19:49:27 +00:00
|
|
|
if (( sb->totpoint-a == bs->v2) || ( sb->totpoint-a == bs->v1)) {
|
2008-08-11 20:40:29 +00:00
|
|
|
attached=1;
|
|
|
|
continue;}
|
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (!attached) {
|
|
|
|
float f = tune / (distance) + tune / (compare * compare) * distance - 2.0f * tune/compare;
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mid_v3_v3v3(velcenter, bp->vec, obp->vec);
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(dvel, velcenter, bp->vec);
|
|
|
|
mul_v3_fl(dvel, _final_mass(ob, bp));
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, def, f * (1.0f - sb->balldamp));
|
|
|
|
madd_v3_v3fl(bp->force, dvel, sb->balldamp);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
/* exploit force(a, b) == -force(b, a) part2/2 */
|
|
|
|
sub_v3_v3v3(dvel, velcenter, obp->vec);
|
|
|
|
mul_v3_fl(dvel, (_final_mass(ob, bp)+_final_mass(ob, obp))/2.0f);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(obp->force, dvel, sb->balldamp);
|
|
|
|
madd_v3_v3fl(obp->force, def, -f * (1.0f - sb->balldamp));
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
|
|
|
/* naive ball self collision done */
|
2008-01-09 00:25:51 +00:00
|
|
|
|
2014-09-29 15:51:47 +10:00
|
|
|
if (_final_goal(ob, bp) < SOFTGOALSNAP) { /* omit this bp when it snaps */
|
2010-06-14 23:56:12 +00:00
|
|
|
float auxvect[3];
|
2008-08-11 20:40:29 +00:00
|
|
|
float velgoal[3];
|
|
|
|
|
|
|
|
/* do goal stuff */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->softflag & OB_SB_GOAL) {
|
2008-08-11 20:40:29 +00:00
|
|
|
/* true elastic goal */
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(auxvect, bp->pos, bp->origT);
|
2012-02-27 10:35:39 +00:00
|
|
|
ks = 1.0f / (1.0f- _final_goal(ob, bp) * sb->goalspring) - 1.0f;
|
2008-08-11 20:40:29 +00:00
|
|
|
bp->force[0]+= -ks*(auxvect[0]);
|
|
|
|
bp->force[1]+= -ks*(auxvect[1]);
|
|
|
|
bp->force[2]+= -ks*(auxvect[2]);
|
|
|
|
|
|
|
|
/* calulate damping forces generated by goals*/
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(velgoal, bp->origS, bp->origE);
|
2012-02-27 10:35:39 +00:00
|
|
|
kd = sb->goalfrict * sb_fric_force_scale(ob);
|
2012-04-29 15:47:02 +00:00
|
|
|
add_v3_v3v3(auxvect, velgoal, bp->vec);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2011-11-11 12:00:08 +00:00
|
|
|
if (forcetime > 0.0f) { /* make sure friction does not become rocket motor on time reversal */
|
2008-08-11 20:40:29 +00:00
|
|
|
bp->force[0]-= kd * (auxvect[0]);
|
|
|
|
bp->force[1]-= kd * (auxvect[1]);
|
|
|
|
bp->force[2]-= kd * (auxvect[2]);
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bp->force[0]-= kd * (velgoal[0] - bp->vec[0]);
|
|
|
|
bp->force[1]-= kd * (velgoal[1] - bp->vec[1]);
|
|
|
|
bp->force[2]-= kd * (velgoal[2] - bp->vec[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* done goal stuff */
|
|
|
|
|
|
|
|
|
|
|
|
/* gravitation */
|
2012-04-29 15:47:02 +00:00
|
|
|
madd_v3_v3fl(bp->force, gravity, _final_mass(ob, bp)); /* individual mass of node here */
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* particle field & vortex */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (do_effector) {
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
EffectedPoint epoint;
|
2012-10-22 08:15:51 +00:00
|
|
|
float force[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
float speed[3] = {0.0f, 0.0f, 0.0f};
|
2008-08-11 20:40:29 +00:00
|
|
|
float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint);
|
|
|
|
pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
/* apply forcefield*/
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(force, fieldfactor* eval_sb_fric_force_scale);
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(bp->force, force);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
/* BP friction in moving media */
|
|
|
|
kd= sb->mediafrict* eval_sb_fric_force_scale;
|
2008-08-11 20:40:29 +00:00
|
|
|
bp->force[0] -= kd * (bp->vec[0] + windfactor*speed[0]/eval_sb_fric_force_scale);
|
|
|
|
bp->force[1] -= kd * (bp->vec[1] + windfactor*speed[1]/eval_sb_fric_force_scale);
|
|
|
|
bp->force[2] -= kd * (bp->vec[2] + windfactor*speed[2]/eval_sb_fric_force_scale);
|
|
|
|
/* now we'll have nice centrifugal effect for vortex */
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* BP friction in media (not) moving*/
|
2010-06-14 23:56:12 +00:00
|
|
|
kd= sb->mediafrict* sb_fric_force_scale(ob);
|
2008-08-11 20:40:29 +00:00
|
|
|
/* assume it to be proportional to actual velocity */
|
|
|
|
bp->force[0]-= bp->vec[0]*kd;
|
|
|
|
bp->force[1]-= bp->vec[1]*kd;
|
|
|
|
bp->force[2]-= bp->vec[2]*kd;
|
|
|
|
/* friction in media done */
|
|
|
|
}
|
|
|
|
/* +++cached collision targets */
|
|
|
|
bp->choke = 0.0f;
|
|
|
|
bp->choke2 = 0.0f;
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->loc_flag &= ~SBF_DOFUZZY;
|
2012-02-23 02:17:50 +00:00
|
|
|
if (do_deflector) {
|
2012-04-29 15:47:02 +00:00
|
|
|
float cfforce[3], defforce[3] ={0.0f, 0.0f, 0.0f}, vel[3] = {0.0f, 0.0f, 0.0f}, facenormal[3], cf = 1.0f, intrusion;
|
2008-08-11 20:40:29 +00:00
|
|
|
kd = 1.0f;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (sb_deflect_face(ob, bp->pos, facenormal, defforce, &cf, timenow, vel, &intrusion)) {
|
2015-11-22 21:12:20 +01:00
|
|
|
if (intrusion < 0.0f) {
|
2012-08-08 18:21:54 +00:00
|
|
|
if (G.debug_value & 0x01) { // 17 we did check for bit 0x10 before
|
2010-06-14 23:56:12 +00:00
|
|
|
/*fixing bug [17428] this forces adaptive step size to tiny steps
|
2012-08-08 18:21:54 +00:00
|
|
|
in some situations .. keeping G.debug_value==17 option for old files 'needing' the bug
|
2008-09-05 23:28:28 +00:00
|
|
|
*/
|
2010-06-14 23:56:12 +00:00
|
|
|
/*bjornmose: uugh.. what an evil hack
|
|
|
|
violation of the 'don't touch bp->pos in here' rule
|
2008-09-05 23:28:28 +00:00
|
|
|
but works nice, like this-->
|
2012-03-09 00:41:09 +00:00
|
|
|
we predict the solution being out of the collider
|
2008-09-05 23:28:28 +00:00
|
|
|
in heun step No1 and leave the heun step No2 adapt to it
|
2010-06-14 23:56:12 +00:00
|
|
|
so we kind of introduced a implicit solver for this case
|
2008-09-05 23:28:28 +00:00
|
|
|
*/
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->pos, facenormal, -intrusion);
|
2008-09-05 23:28:28 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2008-09-05 23:28:28 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(cfforce, bp->vec, vel);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, cfforce, -cf * 50.0f);
|
2008-09-05 23:28:28 +00:00
|
|
|
}
|
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
sb->scratch->flag |= SBF_DOFUZZY;
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->loc_flag |= SBF_DOFUZZY;
|
2008-08-11 20:40:29 +00:00
|
|
|
bp->choke = sb->choke*0.01f;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2012-04-29 15:47:02 +00:00
|
|
|
sub_v3_v3v3(cfforce, bp->vec, vel);
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, cfforce, -cf * 50.0f);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
2015-07-31 14:00:07 +10:00
|
|
|
madd_v3_v3fl(bp->force, defforce, kd);
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/* ---cached collision targets */
|
|
|
|
|
|
|
|
/* +++springs */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->bspring) { /* spring list exists at all ? */
|
2015-11-23 11:27:02 +11:00
|
|
|
for (int b = bp->nofsprings; b > 0; b--) {
|
2008-08-11 20:40:29 +00:00
|
|
|
bs = sb->bspring + bp->springs[b-1];
|
2012-02-27 10:35:39 +00:00
|
|
|
if (do_springcollision || do_aero) {
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(bp->force, bs->ext_force);
|
2008-08-11 20:40:29 +00:00
|
|
|
if (bs->flag & BSF_INTERSECT)
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->choke = bs->cf;
|
2008-08-11 20:40:29 +00:00
|
|
|
|
|
|
|
}
|
2015-11-22 21:12:20 +01:00
|
|
|
// sb_spring_force(Object *ob, int bpi, BodySpring *bs, float iks, float forcetime)
|
2008-08-11 20:40:29 +00:00
|
|
|
// rather remove nl_falgs from code .. will make things a lot cleaner
|
2015-11-22 21:12:20 +01:00
|
|
|
sb_spring_force(ob, sb->totpoint-a, bs, iks, forcetime);
|
2008-08-11 20:40:29 +00:00
|
|
|
}/* loop springs */
|
2010-06-14 23:56:12 +00:00
|
|
|
}/* existing spring list */
|
2008-08-11 20:40:29 +00:00
|
|
|
}/*any edges*/
|
|
|
|
/* ---springs */
|
|
|
|
}/*omit on snap */
|
|
|
|
}/*loop all bp's*/
|
|
|
|
|
|
|
|
|
|
|
|
/* finally add forces caused by face collision */
|
2012-04-29 15:47:02 +00:00
|
|
|
if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob, timenow);
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
pdEndEffectors(&do_effector);
|
2008-08-11 20:40:29 +00:00
|
|
|
}
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
2008-08-11 20:40:29 +00:00
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
static void softbody_apply_forces(Object *ob, float forcetime, int mode, float *err, int mid_flags)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2005-01-12 22:28:13 +00:00
|
|
|
/* time evolution */
|
|
|
|
/* actually does an explicit euler step mode == 0 */
|
2012-04-29 15:47:02 +00:00
|
|
|
/* or heun ~ 2nd order runge-kutta steps, mode 1, 2 */
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2004-10-01 14:10:30 +00:00
|
|
|
BodyPoint *bp;
|
2012-10-22 08:15:51 +00:00
|
|
|
float dx[3] = {0}, dv[3], aabbmin[3], aabbmax[3], cm[3] = {0.0f, 0.0f, 0.0f};
|
2012-04-29 15:47:02 +00:00
|
|
|
float timeovermass/*, freezeloc=0.00001f, freezeforce=0.00000000001f*/;
|
|
|
|
float maxerrpos= 0.0f, maxerrvel = 0.0f;
|
|
|
|
int a, fuzzy=0;
|
2005-04-12 21:36:21 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
forcetime *= sb_time_scale(ob);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
aabbmin[0]=aabbmin[1]=aabbmin[2] = 1e20f;
|
|
|
|
aabbmax[0]=aabbmax[1]=aabbmax[2] = -1e20f;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-07-16 23:23:33 +00:00
|
|
|
/* old one with homogeneous masses */
|
2005-11-19 21:35:06 +00:00
|
|
|
/* claim a minimum mass for vertex */
|
2009-06-24 23:42:45 +00:00
|
|
|
/*
|
2006-11-16 20:57:02 +00:00
|
|
|
if (sb->nodemass > 0.009999f) timeovermass = forcetime/sb->nodemass;
|
|
|
|
else timeovermass = forcetime/0.009999f;
|
2009-06-24 23:42:45 +00:00
|
|
|
*/
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2009-06-24 23:42:45 +00:00
|
|
|
/* now we have individual masses */
|
|
|
|
/* claim a minimum mass for vertex */
|
2012-04-29 15:47:02 +00:00
|
|
|
if (_final_mass(ob, bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob, bp);
|
2011-04-21 15:53:30 +00:00
|
|
|
else timeovermass = forcetime/0.009999f;
|
2009-06-24 23:42:45 +00:00
|
|
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (_final_goal(ob, bp) < SOFTGOALSNAP) {
|
2010-03-22 09:30:00 +00:00
|
|
|
/* this makes t~ = t */
|
2012-04-29 15:47:02 +00:00
|
|
|
if (mid_flags & MID_PRESERVE) copy_v3_v3(dx, bp->vec);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-05 20:28:32 +00:00
|
|
|
/* so here is (v)' = a(cceleration) = sum(F_springs)/m + gravitation + some friction forces + more forces*/
|
2005-04-16 14:01:49 +00:00
|
|
|
/* the ( ... )' operator denotes derivate respective time */
|
2005-01-12 22:28:13 +00:00
|
|
|
/* the euler step for velocity then becomes */
|
2010-06-14 23:56:12 +00:00
|
|
|
/* v(t + dt) = v(t) + a(t) * dt */
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(bp->force, timeovermass);/* individual mass of node here */
|
2005-01-12 22:28:13 +00:00
|
|
|
/* some nasty if's to have heun in here too */
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(dv, bp->force);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mode == 1) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->prevvec, bp->vec);
|
|
|
|
copy_v3_v3(bp->prevdv, dv);
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2007-10-18 22:47:55 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mode ==2) {
|
2005-01-12 22:28:13 +00:00
|
|
|
/* be optimistic and execute step */
|
|
|
|
bp->vec[0] = bp->prevvec[0] + 0.5f * (dv[0] + bp->prevdv[0]);
|
|
|
|
bp->vec[1] = bp->prevvec[1] + 0.5f * (dv[1] + bp->prevdv[1]);
|
|
|
|
bp->vec[2] = bp->prevvec[2] + 0.5f * (dv[2] + bp->prevdv[2]);
|
|
|
|
/* compare euler to heun to estimate error for step sizing */
|
2013-12-01 12:37:05 +11:00
|
|
|
maxerrvel = max_ff(maxerrvel, fabsf(dv[0] - bp->prevdv[0]));
|
|
|
|
maxerrvel = max_ff(maxerrvel, fabsf(dv[1] - bp->prevdv[1]));
|
|
|
|
maxerrvel = max_ff(maxerrvel, fabsf(dv[2] - bp->prevdv[2]));
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2011-11-06 16:38:21 +00:00
|
|
|
else { add_v3_v3(bp->vec, bp->force); }
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
/* this makes t~ = t+dt */
|
2012-04-29 15:47:02 +00:00
|
|
|
if (!(mid_flags & MID_PRESERVE)) copy_v3_v3(dx, bp->vec);
|
2008-01-31 23:00:08 +00:00
|
|
|
|
2005-04-05 20:28:32 +00:00
|
|
|
/* so here is (x)'= v(elocity) */
|
2005-01-12 22:28:13 +00:00
|
|
|
/* the euler step for location then becomes */
|
2010-06-14 23:56:12 +00:00
|
|
|
/* x(t + dt) = x(t) + v(t~) * dt */
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(dx, forcetime);
|
2008-01-31 23:00:08 +00:00
|
|
|
|
2008-08-11 20:40:29 +00:00
|
|
|
/* the freezer coming sooner or later */
|
2013-12-01 12:37:05 +11:00
|
|
|
#if 0
|
2012-04-29 15:47:02 +00:00
|
|
|
if ((dot_v3v3(dx, dx)<freezeloc )&&(dot_v3v3(bp->force, bp->force)<freezeforce )) {
|
2008-01-31 23:00:08 +00:00
|
|
|
bp->frozen /=2;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
2013-12-01 12:37:05 +11:00
|
|
|
bp->frozen = min_ff(bp->frozen*1.05f, 1.0f);
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(dx, bp->frozen);
|
2013-12-01 12:37:05 +11:00
|
|
|
#endif
|
2005-01-12 22:28:13 +00:00
|
|
|
/* again some nasty if's to have heun in here too */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mode ==1) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->prevpos, bp->pos);
|
|
|
|
copy_v3_v3(bp->prevdx, dx);
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (mode ==2) {
|
2005-01-12 22:28:13 +00:00
|
|
|
bp->pos[0] = bp->prevpos[0] + 0.5f * ( dx[0] + bp->prevdx[0]);
|
|
|
|
bp->pos[1] = bp->prevpos[1] + 0.5f * ( dx[1] + bp->prevdx[1]);
|
2008-01-31 23:00:08 +00:00
|
|
|
bp->pos[2] = bp->prevpos[2] + 0.5f * ( dx[2] + bp->prevdx[2]);
|
2013-12-01 12:37:05 +11:00
|
|
|
maxerrpos = max_ff(maxerrpos, fabsf(dx[0] - bp->prevdx[0]));
|
|
|
|
maxerrpos = max_ff(maxerrpos, fabsf(dx[1] - bp->prevdx[1]));
|
|
|
|
maxerrpos = max_ff(maxerrpos, fabsf(dx[2] - bp->prevdx[2]));
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-05-01 17:51:03 +00:00
|
|
|
/* bp->choke is set when we need to pull a vertex or edge out of the collider.
|
|
|
|
* the collider object signals to get out by pushing hard. on the other hand
|
|
|
|
* we don't want to end up in deep space so we add some <viscosity>
|
|
|
|
* to balance that out */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bp->choke2 > 0.0f) {
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(bp->vec, (1.0f - bp->choke2));
|
2008-01-31 23:00:08 +00:00
|
|
|
}
|
2012-02-27 10:35:39 +00:00
|
|
|
if (bp->choke > 0.0f) {
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(bp->vec, (1.0f - bp->choke));
|
2005-04-12 21:36:21 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2005-04-12 21:36:21 +00:00
|
|
|
}
|
2011-11-06 16:38:21 +00:00
|
|
|
else { add_v3_v3(bp->pos, dx);}
|
2005-11-19 21:35:06 +00:00
|
|
|
}/*snap*/
|
2006-11-10 23:09:16 +00:00
|
|
|
/* so while we are looping BPs anyway do statistics on the fly */
|
2013-12-01 12:37:05 +11:00
|
|
|
minmax_v3v3_v3(aabbmin, aabbmax, bp->pos);
|
2010-06-14 23:56:12 +00:00
|
|
|
if (bp->loc_flag & SBF_DOFUZZY) fuzzy =1;
|
2005-11-19 21:35:06 +00:00
|
|
|
} /*for*/
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
if (sb->totpoint) mul_v3_fl(cm, 1.0f/sb->totpoint);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(sb->scratch->aabbmin, aabbmin);
|
|
|
|
copy_v3_v3(sb->scratch->aabbmax, aabbmax);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (err) { /* so step size will be controlled by biggest difference in slope */
|
2006-11-16 20:57:02 +00:00
|
|
|
if (sb->solverflags & SBSO_OLDERR)
|
2013-12-01 12:37:05 +11:00
|
|
|
*err = max_ff(maxerrpos, maxerrvel);
|
2006-11-16 20:57:02 +00:00
|
|
|
else
|
2013-12-01 12:37:05 +11:00
|
|
|
*err = maxerrpos;
|
2012-04-29 15:47:02 +00:00
|
|
|
//printf("EP %f EV %f\n", maxerrpos, maxerrvel);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (fuzzy) {
|
2006-11-10 23:09:16 +00:00
|
|
|
*err /= sb->fuzzyness;
|
|
|
|
}
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
/* used by heun when it overshoots */
|
|
|
|
static void softbody_restore_prev_step(Object *ob)
|
|
|
|
{
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there*/
|
2005-01-12 22:28:13 +00:00
|
|
|
BodyPoint *bp;
|
2004-10-01 14:10:30 +00:00
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->vec, bp->prevvec);
|
|
|
|
copy_v3_v3(bp->pos, bp->prevpos);
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
|
2008-02-25 04:38:48 +00:00
|
|
|
#if 0
|
2008-01-09 00:25:51 +00:00
|
|
|
static void softbody_store_step(Object *ob)
|
|
|
|
{
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there*/
|
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->prevvec, bp->vec);
|
|
|
|
copy_v3_v3(bp->prevpos, bp->pos);
|
2008-01-09 00:25:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* used by predictors and correctors */
|
2012-04-29 15:47:02 +00:00
|
|
|
static void softbody_store_state(Object *ob, float *ppos, float *pvel)
|
2008-01-09 00:25:51 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there*/
|
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
float *pp=ppos, *pv=pvel;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(pv, bp->vec);
|
2008-01-09 00:25:51 +00:00
|
|
|
pv+=3;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(pp, bp->pos);
|
2008-01-09 00:25:51 +00:00
|
|
|
pp+=3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* used by predictors and correctors */
|
2012-04-29 15:47:02 +00:00
|
|
|
static void softbody_retrieve_state(Object *ob, float *ppos, float *pvel)
|
2008-01-09 00:25:51 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there*/
|
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
float *pp=ppos, *pv=pvel;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->vec, pv);
|
2008-01-09 00:25:51 +00:00
|
|
|
pv+=3;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->pos, pp);
|
2008-01-09 00:25:51 +00:00
|
|
|
pp+=3;
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-09 00:25:51 +00:00
|
|
|
/* used by predictors and correctors */
|
2012-04-29 15:47:02 +00:00
|
|
|
static void softbody_swap_state(Object *ob, float *ppos, float *pvel)
|
2005-01-12 22:28:13 +00:00
|
|
|
{
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there*/
|
2005-01-12 22:28:13 +00:00
|
|
|
BodyPoint *bp;
|
2004-10-01 14:10:30 +00:00
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
float *pp=ppos, *pv=pvel;
|
2008-01-09 00:25:51 +00:00
|
|
|
float temp[3];
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(temp, bp->vec);
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->vec, pv);
|
|
|
|
copy_v3_v3(pv, temp);
|
2008-01-09 00:25:51 +00:00
|
|
|
pv+=3;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(temp, bp->pos);
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(bp->pos, pp);
|
|
|
|
copy_v3_v3(pp, temp);
|
2008-01-09 00:25:51 +00:00
|
|
|
pp+=3;
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-25 04:38:48 +00:00
|
|
|
#endif
|
2008-01-09 00:25:51 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
|
2006-01-31 22:48:41 +00:00
|
|
|
/* care for bodypoints taken out of the 'ordinary' solver step
|
|
|
|
** because they are screwed to goal by bolts
|
2010-06-14 23:56:12 +00:00
|
|
|
** they just need to move along with the goal in time
|
|
|
|
** we need to adjust them on sub frame timing in solver
|
2006-01-31 22:48:41 +00:00
|
|
|
** so now when frame is done .. put 'em to the position at the end of frame
|
|
|
|
*/
|
2005-01-12 22:28:13 +00:00
|
|
|
static void softbody_apply_goalsnap(Object *ob)
|
|
|
|
{
|
2005-11-19 21:35:06 +00:00
|
|
|
SoftBody *sb= ob->soft; /* is supposed to be there */
|
2005-01-12 22:28:13 +00:00
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2012-04-29 15:47:02 +00:00
|
|
|
if (_final_goal(ob, bp) >= SOFTGOALSNAP) {
|
|
|
|
copy_v3_v3(bp->prevpos, bp->pos);
|
|
|
|
copy_v3_v3(bp->pos, bp->origT);
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-01 23:20:29 +00:00
|
|
|
|
2008-09-29 17:08:11 +00:00
|
|
|
static void apply_spring_memory(Object *ob)
|
2008-02-01 23:20:29 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb = ob->soft;
|
|
|
|
BodySpring *bs;
|
|
|
|
BodyPoint *bp1, *bp2;
|
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
float b, l, r;
|
2008-02-01 23:20:29 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb && sb->totspring) {
|
2009-06-08 20:08:19 +00:00
|
|
|
b = sb->plastic;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<sb->totspring; a++) {
|
2008-02-01 23:20:29 +00:00
|
|
|
bs = &sb->bspring[a];
|
|
|
|
bp1 =&sb->bpoint[bs->v1];
|
|
|
|
bp2 =&sb->bpoint[bs->v2];
|
2012-04-29 15:47:02 +00:00
|
|
|
l = len_v3v3(bp1->pos, bp2->pos);
|
2008-02-01 23:20:29 +00:00
|
|
|
r = bs->len/l;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (( r > 1.05f) || (r < 0.95f)) {
|
2018-04-16 17:08:27 +02:00
|
|
|
bs->len = ((100.0f - b) * bs->len + b*l)/100.0f;
|
2008-02-01 23:20:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* expects full initialized softbody */
|
2005-01-12 22:28:13 +00:00
|
|
|
static void interpolate_exciter(Object *ob, int timescale, int time)
|
|
|
|
{
|
2005-04-02 13:57:23 +00:00
|
|
|
SoftBody *sb= ob->soft;
|
2005-01-12 22:28:13 +00:00
|
|
|
BodyPoint *bp;
|
|
|
|
float f;
|
2005-04-02 13:57:23 +00:00
|
|
|
int a;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
f = (float)time/(float)timescale;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
bp->origT[0] = bp->origS[0] + f*(bp->origE[0] - bp->origS[0]);
|
|
|
|
bp->origT[1] = bp->origS[1] + f*(bp->origE[1] - bp->origS[1]);
|
|
|
|
bp->origT[2] = bp->origS[2] + f*(bp->origE[2] - bp->origS[2]);
|
2012-04-29 15:47:02 +00:00
|
|
|
if (_final_goal(ob, bp) >= SOFTGOALSNAP) {
|
2005-04-02 13:57:23 +00:00
|
|
|
bp->vec[0] = bp->origE[0] - bp->origS[0];
|
|
|
|
bp->vec[1] = bp->origE[1] - bp->origS[1];
|
|
|
|
bp->vec[2] = bp->origE[2] - bp->origS[2];
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
|
|
|
|
/* ************ convertors ********** */
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* for each object type we need;
|
2010-03-22 09:30:00 +00:00
|
|
|
- xxxx_to_softbody(Object *ob) : a full (new) copy, creates SB geometry
|
2005-04-02 13:57:23 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
/* Resetting a Mesh SB object's springs */
|
2010-07-25 01:45:53 +00:00
|
|
|
/* Spring length are caculted from'raw' mesh vertices that are NOT altered by modifier stack. */
|
2005-10-21 22:58:12 +00:00
|
|
|
static void springs_from_mesh(Object *ob)
|
|
|
|
{
|
|
|
|
SoftBody *sb;
|
|
|
|
Mesh *me= ob->data;
|
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2007-10-18 22:47:55 +00:00
|
|
|
float scale =1.0f;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
sb= ob->soft;
|
2012-04-28 06:31:57 +00:00
|
|
|
if (me && sb) {
|
2018-04-16 17:08:27 +02:00
|
|
|
/* using bp->origS as a container for spring calcualtions here
|
|
|
|
* will be overwritten sbObjectStep() to receive
|
|
|
|
* actual modifier stack positions
|
|
|
|
*/
|
2012-02-23 02:17:50 +00:00
|
|
|
if (me->totvert) {
|
2005-10-21 22:58:12 +00:00
|
|
|
bp= ob->soft->bpoint;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<me->totvert; a++, bp++) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->origS, me->mvert[a].co);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, bp->origS);
|
2005-10-21 22:58:12 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-10-21 22:58:12 +00:00
|
|
|
}
|
|
|
|
/* recalculate spring length for meshes here */
|
2008-04-05 21:29:17 +00:00
|
|
|
/* public version shrink to fit */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->springpreload != 0 ) {
|
2008-04-05 21:29:17 +00:00
|
|
|
scale = sb->springpreload / 100.0f;
|
2007-10-18 22:47:55 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<sb->totspring; a++) {
|
2005-10-21 22:58:12 +00:00
|
|
|
BodySpring *bs = &sb->bspring[a];
|
2009-11-10 20:43:45 +00:00
|
|
|
bs->len= scale*len_v3v3(sb->bpoint[bs->v1].origS, sb->bpoint[bs->v2].origS);
|
2005-10-21 22:58:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-09 23:30:32 +00:00
|
|
|
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
/* makes totally fresh start situation */
|
2009-01-04 14:14:06 +00:00
|
|
|
static void mesh_to_softbody(Scene *scene, Object *ob)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2005-04-02 13:57:23 +00:00
|
|
|
SoftBody *sb;
|
2004-10-01 14:10:30 +00:00
|
|
|
Mesh *me= ob->data;
|
|
|
|
MEdge *medge= me->medge;
|
|
|
|
BodyPoint *bp;
|
|
|
|
BodySpring *bs;
|
2005-04-03 20:13:10 +00:00
|
|
|
int a, totedge;
|
2015-07-14 06:10:56 +10:00
|
|
|
int defgroup_index, defgroup_index_mass, defgroup_index_spring;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2005-04-03 20:13:10 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) totedge= me->totedge;
|
|
|
|
else totedge= 0;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
|
2009-01-04 14:14:06 +00:00
|
|
|
renew_softbody(scene, ob, me->totvert, totedge);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* we always make body points */
|
2015-07-14 06:10:56 +10:00
|
|
|
sb = ob->soft;
|
2005-04-02 13:57:23 +00:00
|
|
|
bp= sb->bpoint;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
defgroup_index = me->dvert ? (sb->vertgroup - 1) : -1;
|
|
|
|
defgroup_index_mass = me->dvert ? defgroup_name_index(ob, sb->namedVG_Mass) : -1;
|
|
|
|
defgroup_index_spring = me->dvert ? defgroup_name_index(ob, sb->namedVG_Spring_K) : -1;
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<me->totvert; a++, bp++) {
|
2005-04-16 14:01:49 +00:00
|
|
|
/* get scalar values needed *per vertex* from vertex group functions,
|
2012-05-16 23:37:23 +00:00
|
|
|
* so we can *paint* them nicly ..
|
|
|
|
* they are normalized [0.0..1.0] so may be we need amplitude for scale
|
|
|
|
* which can be done by caller but still .. i'd like it to go this way
|
|
|
|
*/
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
if (ob->softflag & OB_SB_GOAL) {
|
|
|
|
BLI_assert(bp->goal == sb->defgoal);
|
2010-03-13 02:43:25 +00:00
|
|
|
}
|
2015-07-14 06:10:56 +10:00
|
|
|
if ((ob->softflag & OB_SB_GOAL) && (defgroup_index != -1)) {
|
|
|
|
bp->goal *= defvert_find_weight(&me->dvert[a], defgroup_index);
|
2005-04-16 14:01:49 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-07-26 17:41:09 +00:00
|
|
|
/* to proof the concept
|
2012-05-16 23:37:23 +00:00
|
|
|
* this enables per vertex *mass painting*
|
|
|
|
*/
|
2009-06-24 23:42:45 +00:00
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
if (defgroup_index_mass != -1) {
|
|
|
|
bp->mass *= defvert_find_weight(&me->dvert[a], defgroup_index_mass);
|
2009-06-24 23:42:45 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
if (defgroup_index_spring != -1) {
|
|
|
|
bp->springweight *= defvert_find_weight(&me->dvert[a], defgroup_index_spring);
|
2009-06-24 23:42:45 +00:00
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
}
|
2005-01-12 22:28:13 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* but we only optionally add body edge springs */
|
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-02-23 02:17:50 +00:00
|
|
|
if (medge) {
|
2005-04-02 13:57:23 +00:00
|
|
|
bs= sb->bspring;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=me->totedge; a>0; a--, medge++, bs++) {
|
2004-10-01 14:10:30 +00:00
|
|
|
bs->v1= medge->v1;
|
|
|
|
bs->v2= medge->v2;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_EDGE;
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
|
2005-04-03 20:13:10 +00:00
|
|
|
/* insert *diagonal* springs in quads if desired */
|
|
|
|
if (ob->softflag & OB_SB_QUADS) {
|
|
|
|
add_mesh_quad_diag_springs(ob);
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-10-21 22:58:12 +00:00
|
|
|
build_bps_springlist(ob); /* scan for springs attached to bodypoints ONCE */
|
2006-09-26 12:53:57 +00:00
|
|
|
/* insert *other second order* springs if desired */
|
|
|
|
if (sb->secondspring > 0.0000001f) {
|
2014-10-29 14:11:19 +01:00
|
|
|
add_2nd_order_springs(ob, sb->secondspring); /* exploits the first run of build_bps_springlist(ob);*/
|
2006-09-26 12:53:57 +00:00
|
|
|
build_bps_springlist(ob); /* yes we need to do it again*/
|
|
|
|
}
|
2010-07-25 01:45:53 +00:00
|
|
|
springs_from_mesh(ob); /* write the 'rest'-length of the springs */
|
2011-11-11 13:09:14 +00:00
|
|
|
if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-03 20:13:10 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2005-11-19 20:02:30 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
static void mesh_faces_to_scratch(Object *ob)
|
|
|
|
{
|
2010-06-14 23:56:12 +00:00
|
|
|
SoftBody *sb= ob->soft;
|
2015-07-31 19:01:51 +10:00
|
|
|
const Mesh *me = ob->data;
|
|
|
|
MLoopTri *looptri, *lt;
|
2006-11-10 23:09:16 +00:00
|
|
|
BodyFace *bodyface;
|
|
|
|
int a;
|
|
|
|
/* alloc and copy faces*/
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-31 19:01:51 +10:00
|
|
|
sb->scratch->totface = poly_to_tri_count(me->totpoly, me->totloop);
|
|
|
|
looptri = lt = MEM_mallocN(sizeof(*looptri) * sb->scratch->totface, __func__);
|
|
|
|
BKE_mesh_recalc_looptri(
|
|
|
|
me->mloop, me->mpoly,
|
|
|
|
me->mvert,
|
|
|
|
me->totloop, me->totpoly,
|
|
|
|
looptri);
|
|
|
|
|
|
|
|
bodyface = sb->scratch->bodyface = MEM_mallocN(sizeof(BodyFace) * sb->scratch->totface, "SB_body_Faces");
|
|
|
|
|
|
|
|
for (a = 0; a < sb->scratch->totface; a++, lt++, bodyface++) {
|
|
|
|
bodyface->v1 = me->mloop[lt->tri[0]].v;
|
|
|
|
bodyface->v2 = me->mloop[lt->tri[1]].v;
|
|
|
|
bodyface->v3 = me->mloop[lt->tri[2]].v;
|
|
|
|
zero_v3(bodyface->ext_force);
|
2006-11-10 23:09:16 +00:00
|
|
|
bodyface->ext_force[0] = bodyface->ext_force[1] = bodyface->ext_force[2] = 0.0f;
|
2015-07-31 19:01:51 +10:00
|
|
|
bodyface->flag = 0;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2015-07-31 19:01:51 +10:00
|
|
|
|
|
|
|
MEM_freeN(looptri);
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
2009-11-21 22:45:25 +00:00
|
|
|
static void reference_to_scratch(Object *ob)
|
|
|
|
{
|
2010-06-14 23:56:12 +00:00
|
|
|
SoftBody *sb= ob->soft;
|
2009-11-21 22:45:25 +00:00
|
|
|
ReferenceVert *rp;
|
|
|
|
BodyPoint *bp;
|
2012-04-29 15:47:02 +00:00
|
|
|
float accu_pos[3] ={0.f, 0.f, 0.f};
|
2009-11-21 22:45:25 +00:00
|
|
|
float accu_mass = 0.f;
|
|
|
|
int a;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
sb->scratch->Ref.ivert = MEM_mallocN(sizeof(ReferenceVert)*sb->totpoint, "SB_Reference");
|
2009-11-21 22:45:25 +00:00
|
|
|
bp= ob->soft->bpoint;
|
|
|
|
rp= sb->scratch->Ref.ivert;
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<sb->totpoint; a++, rp++, bp++) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(rp->pos, bp->pos);
|
2011-11-06 16:38:21 +00:00
|
|
|
add_v3_v3(accu_pos, bp->pos);
|
2012-04-29 15:47:02 +00:00
|
|
|
accu_mass += _final_mass(ob, bp);
|
2009-11-21 22:45:25 +00:00
|
|
|
}
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3_fl(accu_pos, 1.0f/accu_mass);
|
|
|
|
copy_v3_v3(sb->scratch->Ref.com, accu_pos);
|
2012-03-31 00:59:17 +00:00
|
|
|
/* printf("reference_to_scratch\n"); */
|
2009-11-21 22:45:25 +00:00
|
|
|
}
|
2005-11-19 20:02:30 +00:00
|
|
|
|
|
|
|
/*
|
2012-05-16 23:37:23 +00:00
|
|
|
* helper function to get proper spring length
|
|
|
|
* when object is rescaled
|
|
|
|
*/
|
2012-04-29 15:47:02 +00:00
|
|
|
static float globallen(float *v1, float *v2, Object *ob)
|
2005-11-19 20:02:30 +00:00
|
|
|
{
|
2012-04-29 15:47:02 +00:00
|
|
|
float p1[3], p2[3];
|
|
|
|
copy_v3_v3(p1, v1);
|
2010-06-14 23:56:12 +00:00
|
|
|
mul_m4_v3(ob->obmat, p1);
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(p2, v2);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, p2);
|
2012-04-29 15:47:02 +00:00
|
|
|
return len_v3v3(p1, p2);
|
2005-11-19 20:02:30 +00:00
|
|
|
}
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static void makelatticesprings(Lattice *lt, BodySpring *bs, int dostiff, Object *ob)
|
2005-08-03 21:38:02 +00:00
|
|
|
{
|
2005-11-19 18:19:41 +00:00
|
|
|
BPoint *bp=lt->def, *bpu;
|
2005-10-24 22:13:32 +00:00
|
|
|
int u, v, w, dv, dw, bpc=0, bpuc;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-08-03 21:38:02 +00:00
|
|
|
dv= lt->pntsu;
|
|
|
|
dw= dv*lt->pntsv;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (w=0; w<lt->pntsw; w++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (v=0; v<lt->pntsv; v++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (u=0, bpuc=0, bpu=NULL; u<lt->pntsu; u++, bp++, bpc++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (w) {
|
2005-08-03 21:38:02 +00:00
|
|
|
bs->v1 = bpc;
|
|
|
|
bs->v2 = bpc-dw;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_EDGE;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bp-dw)->vec, bp->vec, ob);
|
2005-08-03 21:38:02 +00:00
|
|
|
bs++;
|
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (v) {
|
2005-08-03 21:38:02 +00:00
|
|
|
bs->v1 = bpc;
|
|
|
|
bs->v2 = bpc-dv;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_EDGE;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bp-dv)->vec, bp->vec, ob);
|
2005-08-03 21:38:02 +00:00
|
|
|
bs++;
|
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (u) {
|
2005-08-03 21:38:02 +00:00
|
|
|
bs->v1 = bpuc;
|
|
|
|
bs->v2 = bpc;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_EDGE;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bpu)->vec, bp->vec, ob);
|
2005-08-03 21:38:02 +00:00
|
|
|
bs++;
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-08-03 21:38:02 +00:00
|
|
|
if (dostiff) {
|
2005-08-04 10:41:47 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (w) {
|
2012-02-23 02:17:50 +00:00
|
|
|
if ( v && u ) {
|
2005-08-04 10:41:47 +00:00
|
|
|
bs->v1 = bpc;
|
2005-08-03 21:38:02 +00:00
|
|
|
bs->v2 = bpc-dw-dv-1;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_BEND;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bp-dw-dv-1)->vec, bp->vec, ob);
|
2005-08-04 10:41:47 +00:00
|
|
|
bs++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if ( (v < lt->pntsv-1) && (u != 0) ) {
|
2005-08-04 10:41:47 +00:00
|
|
|
bs->v1 = bpc;
|
|
|
|
bs->v2 = bpc-dw+dv-1;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_BEND;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bp-dw+dv-1)->vec, bp->vec, ob);
|
2005-08-03 21:38:02 +00:00
|
|
|
bs++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2005-08-03 21:38:02 +00:00
|
|
|
}
|
2005-08-04 10:41:47 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (w < lt->pntsw -1) {
|
2012-02-23 02:17:50 +00:00
|
|
|
if ( v && u ) {
|
2005-08-04 10:41:47 +00:00
|
|
|
bs->v1 = bpc;
|
|
|
|
bs->v2 = bpc+dw-dv-1;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_BEND;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen((bp+dw-dv-1)->vec, bp->vec, ob);
|
2005-08-04 10:41:47 +00:00
|
|
|
bs++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if ( (v < lt->pntsv-1) && (u != 0) ) {
|
2005-08-04 10:41:47 +00:00
|
|
|
bs->v1 = bpc;
|
|
|
|
bs->v2 = bpc+dw+dv-1;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_BEND;
|
2015-05-17 16:47:44 +10:00
|
|
|
bs->len= globallen((bp+dw+dv-1)->vec, bp->vec, ob);
|
2005-08-04 10:41:47 +00:00
|
|
|
bs++;
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
2005-08-04 10:41:47 +00:00
|
|
|
}
|
2005-08-03 21:38:02 +00:00
|
|
|
}
|
2005-11-19 18:19:41 +00:00
|
|
|
bpu = bp;
|
2005-08-03 21:38:02 +00:00
|
|
|
bpuc = bpc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
/* makes totally fresh start situation */
|
2009-01-04 14:14:06 +00:00
|
|
|
static void lattice_to_softbody(Scene *scene, Object *ob)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2005-04-02 19:52:32 +00:00
|
|
|
Lattice *lt= ob->data;
|
2005-11-17 11:40:57 +00:00
|
|
|
SoftBody *sb;
|
2012-05-27 13:33:09 +00:00
|
|
|
int totvert, totspring = 0, a;
|
|
|
|
BodyPoint *bp;
|
|
|
|
BPoint *bpnt = lt->def;
|
2015-07-14 06:10:56 +10:00
|
|
|
int defgroup_index, defgroup_index_mass, defgroup_index_spring;
|
2005-10-21 22:58:12 +00:00
|
|
|
|
2005-04-02 19:52:32 +00:00
|
|
|
totvert= lt->pntsu*lt->pntsv*lt->pntsw;
|
2005-08-04 10:41:47 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-05-09 09:24:15 +00:00
|
|
|
totspring = ((lt->pntsu - 1) * lt->pntsv +
|
|
|
|
(lt->pntsv - 1) * lt->pntsu) * lt->pntsw +
|
|
|
|
lt->pntsu*lt->pntsv * (lt->pntsw - 1);
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_QUADS) {
|
2012-05-09 09:24:15 +00:00
|
|
|
totspring += 4 * (lt->pntsu - 1) * (lt->pntsv -1) * (lt->pntsw - 1);
|
2005-08-04 10:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-08-04 10:41:47 +00:00
|
|
|
|
2005-04-02 19:52:32 +00:00
|
|
|
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
|
2009-01-04 14:14:06 +00:00
|
|
|
renew_softbody(scene, ob, totvert, totspring);
|
2005-11-17 11:40:57 +00:00
|
|
|
sb= ob->soft; /* can be created in renew_softbody() */
|
2012-05-27 13:33:09 +00:00
|
|
|
bp = sb->bpoint;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
defgroup_index = lt->dvert ? (sb->vertgroup - 1) : -1;
|
|
|
|
defgroup_index_mass = lt->dvert ? defgroup_name_index(ob, sb->namedVG_Mass) : -1;
|
|
|
|
defgroup_index_spring = lt->dvert ? defgroup_name_index(ob, sb->namedVG_Spring_K) : -1;
|
|
|
|
|
2012-05-27 13:33:09 +00:00
|
|
|
/* same code used as for mesh vertices */
|
|
|
|
for (a = 0; a < totvert; a++, bp++, bpnt++) {
|
2015-07-14 06:10:56 +10:00
|
|
|
|
|
|
|
if (ob->softflag & OB_SB_GOAL) {
|
|
|
|
BLI_assert(bp->goal == sb->defgoal);
|
2012-05-27 13:33:09 +00:00
|
|
|
}
|
2015-07-14 06:10:56 +10:00
|
|
|
|
|
|
|
if ((ob->softflag & OB_SB_GOAL) && (defgroup_index != -1)) {
|
|
|
|
bp->goal *= defvert_find_weight(<->dvert[a], defgroup_index);
|
|
|
|
}
|
2015-07-14 06:18:58 +10:00
|
|
|
else {
|
|
|
|
bp->goal *= bpnt->weight;
|
|
|
|
}
|
2015-07-14 06:10:56 +10:00
|
|
|
|
|
|
|
if (defgroup_index_mass != -1) {
|
|
|
|
bp->mass *= defvert_find_weight(<->dvert[a], defgroup_index_mass);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defgroup_index_spring != -1) {
|
|
|
|
bp->springweight *= defvert_find_weight(<->dvert[a], defgroup_index_spring);
|
2005-11-16 21:58:49 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
}
|
|
|
|
|
2015-07-14 06:10:56 +10:00
|
|
|
|
2011-10-17 06:39:13 +00:00
|
|
|
/* create some helper edges to enable SB lattice to be useful at all */
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-04-29 15:47:02 +00:00
|
|
|
makelatticesprings(lt, ob->soft->bspring, ob->softflag & OB_SB_QUADS, ob);
|
2005-08-03 21:38:02 +00:00
|
|
|
build_bps_springlist(ob); /* link bps to springs */
|
2005-04-02 19:52:32 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-01 14:10:30 +00:00
|
|
|
|
2005-11-17 11:40:57 +00:00
|
|
|
/* makes totally fresh start situation */
|
2009-01-04 14:14:06 +00:00
|
|
|
static void curve_surf_to_softbody(Scene *scene, Object *ob)
|
2005-11-17 11:40:57 +00:00
|
|
|
{
|
|
|
|
Curve *cu= ob->data;
|
|
|
|
SoftBody *sb;
|
2005-11-17 12:24:29 +00:00
|
|
|
BodyPoint *bp;
|
|
|
|
BodySpring *bs;
|
|
|
|
Nurb *nu;
|
|
|
|
BezTriple *bezt;
|
|
|
|
BPoint *bpnt;
|
|
|
|
int a, curindex=0;
|
|
|
|
int totvert, totspring = 0, setgoal=0;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-28 16:49:00 +00:00
|
|
|
totvert= BKE_nurbList_verts_count(&cu->nurb);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (ob->softflag & OB_SB_EDGES) {
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->type==OB_CURVE) {
|
2014-11-16 14:23:37 +01:00
|
|
|
totspring = totvert - BLI_listbase_count(&cu->nurb);
|
2005-11-17 11:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-11-17 11:40:57 +00:00
|
|
|
/* renew ends with ob->soft with points and edges, also checks & makes ob->soft */
|
2009-01-04 14:14:06 +00:00
|
|
|
renew_softbody(scene, ob, totvert, totspring);
|
2005-11-17 11:40:57 +00:00
|
|
|
sb= ob->soft; /* can be created in renew_softbody() */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-11-17 12:24:29 +00:00
|
|
|
/* set vars now */
|
|
|
|
bp= sb->bpoint;
|
|
|
|
bs= sb->bspring;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-11-17 11:40:57 +00:00
|
|
|
/* weights from bpoints, same code used as for mesh vertices */
|
2012-02-23 02:17:50 +00:00
|
|
|
/* if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) 2.4x hack*/
|
2010-02-13 00:52:01 +00:00
|
|
|
/* new! take the weights from curve vertex anyhow */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->softflag & OB_SB_GOAL)
|
2005-11-17 12:24:29 +00:00
|
|
|
setgoal= 1;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (nu= cu->nurb.first; nu; nu= nu->next) {
|
|
|
|
if (nu->bezt) {
|
2010-06-11 23:05:43 +00:00
|
|
|
/* bezier case ; this is nicly said naive; who ever wrote this part, it was not me (JOW) :) */
|
2010-06-14 23:56:12 +00:00
|
|
|
/* a: never ever make tangent handles (sub) and or (ob)ject to collision */
|
2012-03-03 11:45:08 +00:00
|
|
|
/* b: rather calculate them using some C2 (C2= continuous in second derivate -> no jump in bending ) condition */
|
2010-06-11 23:05:43 +00:00
|
|
|
/* not too hard to do, but needs some more code to care for; some one may want look at it JOW 2010/06/12*/
|
2012-02-23 02:17:50 +00:00
|
|
|
for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++, bp+=3, curindex+=3) {
|
|
|
|
if (setgoal) {
|
2015-07-14 06:18:58 +10:00
|
|
|
bp->goal *= bezt->weight;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-11-17 12:24:29 +00:00
|
|
|
/* all three triples */
|
|
|
|
(bp+1)->goal= bp->goal;
|
|
|
|
(bp+2)->goal= bp->goal;
|
2010-06-14 23:56:12 +00:00
|
|
|
/*do not collide handles */
|
|
|
|
(bp+1)->loc_flag |= SBF_OUTOFCOLLISION;
|
|
|
|
(bp+2)->loc_flag |= SBF_OUTOFCOLLISION;
|
2005-11-17 12:24:29 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totspring) {
|
|
|
|
if (a>0) {
|
2010-06-15 09:47:37 +00:00
|
|
|
bs->v1= curindex-3;
|
2005-11-17 12:24:29 +00:00
|
|
|
bs->v2= curindex;
|
2010-06-15 09:47:37 +00:00
|
|
|
bs->springtype=SB_HANDLE;
|
2012-04-29 17:11:40 +00:00
|
|
|
bs->len = globallen((bezt-1)->vec[0], bezt->vec[0], ob);
|
2005-11-17 11:40:57 +00:00
|
|
|
bs++;
|
|
|
|
}
|
2005-11-17 12:24:29 +00:00
|
|
|
bs->v1= curindex;
|
|
|
|
bs->v2= curindex+1;
|
2010-06-15 09:47:37 +00:00
|
|
|
bs->springtype=SB_HANDLE;
|
2012-04-29 17:11:40 +00:00
|
|
|
bs->len = globallen(bezt->vec[0], bezt->vec[1], ob);
|
2005-11-17 12:24:29 +00:00
|
|
|
bs++;
|
2009-11-04 00:21:25 +00:00
|
|
|
|
2005-11-17 12:24:29 +00:00
|
|
|
bs->v1= curindex+1;
|
|
|
|
bs->v2= curindex+2;
|
2010-06-15 09:47:37 +00:00
|
|
|
bs->springtype=SB_HANDLE;
|
2012-04-29 17:11:40 +00:00
|
|
|
bs->len = globallen(bezt->vec[1], bezt->vec[2], ob);
|
2005-11-17 12:24:29 +00:00
|
|
|
bs++;
|
2005-11-17 11:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-17 12:24:29 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-02-23 02:17:50 +00:00
|
|
|
for (bpnt=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bpnt++, bp++, curindex++) {
|
|
|
|
if (setgoal) {
|
2015-07-14 06:18:58 +10:00
|
|
|
bp->goal *= bpnt->weight;
|
2005-11-17 12:24:29 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (totspring && a>0) {
|
2005-11-17 12:24:29 +00:00
|
|
|
bs->v1= curindex-1;
|
|
|
|
bs->v2= curindex;
|
2009-11-04 00:21:25 +00:00
|
|
|
bs->springtype=SB_EDGE;
|
2012-04-29 15:47:02 +00:00
|
|
|
bs->len= globallen( (bpnt-1)->vec, bpnt->vec, ob );
|
2005-11-17 12:24:29 +00:00
|
|
|
bs++;
|
2005-11-17 11:40:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
if (totspring) {
|
2005-11-17 11:40:57 +00:00
|
|
|
build_bps_springlist(ob); /* link bps to springs */
|
2006-10-11 22:53:22 +00:00
|
|
|
if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);}
|
2006-10-05 17:46:01 +00:00
|
|
|
}
|
2005-11-17 11:40:57 +00:00
|
|
|
}
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* copies softbody result back in object */
|
2006-03-01 23:45:25 +00:00
|
|
|
static void softbody_to_object(Object *ob, float (*vertexCos)[3], int numVerts, int local)
|
2005-04-02 13:57:23 +00:00
|
|
|
{
|
2009-11-21 22:45:25 +00:00
|
|
|
SoftBody *sb= ob->soft;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb) {
|
2009-11-21 22:45:25 +00:00
|
|
|
BodyPoint *bp= sb->bpoint;
|
|
|
|
int a;
|
2012-04-29 15:47:02 +00:00
|
|
|
if (sb->solverflags & SBSO_ESTIMATEIPO) {SB_estimate_transform(ob, sb->lcom, sb->lrot, sb->lscale);}
|
2009-11-21 22:45:25 +00:00
|
|
|
/* inverse matrix is not uptodate... */
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0; a<numVerts; a++, bp++) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(vertexCos[a], bp->pos);
|
2012-02-23 02:17:50 +00:00
|
|
|
if (local==0)
|
2009-11-21 22:45:25 +00:00
|
|
|
mul_m4_v3(ob->imat, vertexCos[a]); /* softbody is in global coords, baked optionally not */
|
|
|
|
}
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
}
|
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
/* +++ ************ maintaining scratch *************** */
|
2008-09-29 17:08:11 +00:00
|
|
|
static void sb_new_scratch(SoftBody *sb)
|
2006-11-10 23:09:16 +00:00
|
|
|
{
|
|
|
|
if (!sb) return;
|
|
|
|
sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch");
|
2012-05-16 00:51:36 +00:00
|
|
|
sb->scratch->colliderhash = BLI_ghash_ptr_new("sb_new_scratch gh");
|
2006-11-10 23:09:16 +00:00
|
|
|
sb->scratch->bodyface = NULL;
|
|
|
|
sb->scratch->totface = 0;
|
|
|
|
sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f;
|
|
|
|
sb->scratch->aabbmin[0]=sb->scratch->aabbmin[1]=sb->scratch->aabbmin[2] = -1.0e30f;
|
2009-11-21 22:45:25 +00:00
|
|
|
sb->scratch->Ref.ivert = NULL;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
/* --- ************ maintaining scratch *************** */
|
2005-04-02 13:57:23 +00:00
|
|
|
|
|
|
|
/* ************ Object level, exported functions *************** */
|
2004-10-01 14:10:30 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
/* allocates and initializes general main data */
|
2009-01-04 14:14:06 +00:00
|
|
|
SoftBody *sbNew(Scene *scene)
|
2005-04-02 13:57:23 +00:00
|
|
|
{
|
|
|
|
SoftBody *sb;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
sb= MEM_callocN(sizeof(SoftBody), "softbody");
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
sb->mediafrict= 0.5f;
|
2006-10-11 22:53:22 +00:00
|
|
|
sb->nodemass= 1.0f;
|
2010-06-14 23:56:12 +00:00
|
|
|
sb->grav= 9.8f;
|
2006-10-11 22:53:22 +00:00
|
|
|
sb->physics_speed= 1.0f;
|
2006-11-16 20:57:02 +00:00
|
|
|
sb->rklimit= 0.1f;
|
2005-04-22 17:58:39 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
sb->goalspring= 0.5f;
|
|
|
|
sb->goalfrict= 0.0f;
|
|
|
|
sb->mingoal= 0.0f;
|
2006-10-11 22:53:22 +00:00
|
|
|
sb->maxgoal= 1.0f;
|
2005-10-24 22:13:32 +00:00
|
|
|
sb->defgoal= 0.7f;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2006-10-11 22:53:22 +00:00
|
|
|
sb->inspring= 0.5f;
|
2010-06-14 23:56:12 +00:00
|
|
|
sb->infrict= 0.5f;
|
2008-01-10 00:07:31 +00:00
|
|
|
/*todo backward file compat should copy inspring to inpush while reading old files*/
|
2010-06-14 23:56:12 +00:00
|
|
|
sb->inpush = 0.5f;
|
|
|
|
|
2005-05-02 13:28:13 +00:00
|
|
|
sb->interval= 10;
|
2009-01-04 14:14:06 +00:00
|
|
|
sb->sfra= scene->r.sfra;
|
|
|
|
sb->efra= scene->r.efra;
|
2006-10-11 22:53:22 +00:00
|
|
|
|
2006-11-16 20:57:02 +00:00
|
|
|
sb->colball = 0.49f;
|
|
|
|
sb->balldamp = 0.50f;
|
2006-10-11 22:53:22 +00:00
|
|
|
sb->ballstiff= 1.0f;
|
|
|
|
sb->sbc_mode = 1;
|
2007-10-18 22:47:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
sb->minloops = 10;
|
2008-01-09 00:25:51 +00:00
|
|
|
sb->maxloops = 300;
|
2007-10-18 22:47:55 +00:00
|
|
|
|
|
|
|
sb->choke = 3;
|
2006-11-10 23:09:16 +00:00
|
|
|
sb_new_scratch(sb);
|
2008-01-09 00:25:51 +00:00
|
|
|
/*todo backward file compat should set sb->shearstiff = 1.0f while reading old files*/
|
|
|
|
sb->shearstiff = 1.0f;
|
|
|
|
sb->solverflags |= SBSO_OLDERR;
|
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
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
sb->pointcache = BKE_ptcache_add(&sb->ptcaches);
|
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (!sb->effector_weights)
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
sb->effector_weights = BKE_add_effector_weights(NULL);
|
|
|
|
|
2012-01-09 14:08:06 +00:00
|
|
|
sb->last_frame= MINFRAME-1;
|
|
|
|
|
2005-04-02 13:57:23 +00:00
|
|
|
return sb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* frees all */
|
|
|
|
void sbFree(SoftBody *sb)
|
|
|
|
{
|
|
|
|
free_softbody_intern(sb);
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_free_list(&sb->ptcaches);
|
|
|
|
sb->pointcache = NULL;
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->effector_weights)
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
MEM_freeN(sb->effector_weights);
|
2005-04-02 13:57:23 +00:00
|
|
|
MEM_freeN(sb);
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
void sbFreeSimulation(SoftBody *sb)
|
|
|
|
{
|
|
|
|
free_softbody_intern(sb);
|
|
|
|
}
|
2005-04-02 13:57:23 +00:00
|
|
|
|
2004-10-01 14:10:30 +00:00
|
|
|
/* makes totally fresh start situation */
|
2005-08-15 10:30:53 +00:00
|
|
|
void sbObjectToSoftbody(Object *ob)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
//ob->softflag |= OB_SB_REDO;
|
2005-04-16 15:06:02 +00:00
|
|
|
|
2005-08-16 22:58:31 +00:00
|
|
|
free_softbody_intern(ob->soft);
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
static int object_has_edges(Object *ob)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2012-02-23 02:17:50 +00:00
|
|
|
if (ob->type==OB_MESH) {
|
- added mesh_strip_loose_faces, works in conjunction with make_edges
to get rid of faces with MFace.v3==0
- change all Mesh's to have ->medge now. This is forced by make_edges
on readfile, and in the various exotic important routines, and on
conversion back in python.
- make python NMesh structure always have medges now (needs testing)
- with above two changes it is guarenteed that mf->v3 is never ==0
in main blender code (i.e., all MFace's are actually triangles
or quads) and so I went through and removed all the historic tests
to deal with MFace.v3==0. Equals lots of deleting, I am in heaven!
- removed MEdge edcode flag, no longer needed
- added experimental replacement for edge flag system
Still are some inconsistencies in FACESELECT mode edge drawing to
be ironed out.
NOTE: This commit adds an experimental edge flag calc system, based
on 10-seconds-of-thought algorithm by yours truly. Would appreciate
feedback on how this system works, esp compared to old one and esp
on complex or interesting models.
To Use: New system is enabled by setting G.rt to a value between
1 and 1000 (Value of 0 uses old system). Value 1000 is reserved for
"auto" edge, which is more or less identical to old system but also
makes sure that at least 10% of edges are drawn (solves errors for
super subdivided meshes). Values between 1 and 999 act as percent
(out of 1000) of edges that should be drawn, starting with "most
interesting" edges first. Please try it and comment!
2005-08-21 07:19:20 +00:00
|
|
|
return ((Mesh*) ob->data)->totedge;
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
else if (ob->type==OB_LATTICE) {
|
2005-08-15 10:30:53 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 0;
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
/* SB global visible functions */
|
2006-11-20 22:27:05 +00:00
|
|
|
void sbSetInterruptCallBack(int (*f)(void))
|
|
|
|
{
|
|
|
|
SB_localInterruptCallBack = f;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void softbody_update_positions(Object *ob, SoftBody *sb, float (*vertexCos)[3], int numVerts)
|
2004-10-01 14:10:30 +00:00
|
|
|
{
|
2005-08-15 10:30:53 +00:00
|
|
|
BodyPoint *bp;
|
2005-11-19 18:19:41 +00:00
|
|
|
int a;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (!sb || !sb->bpoint)
|
Unified effector functionality for particles, cloth and softbody
* Unified scene wide gravity (currently in scene buttons)
instead of each simulation having it's own gravity.
* Weight parameters for all effectors and an effector group
setting.
* Every effector can use noise.
* Most effectors have "shapes" point, plane, surface, every point.
- "Point" is most like the old effectors and uses the
effector location as the effector point.
- "Plane" uses the closest point on effectors local xy-plane
as the effector point.
- "Surface" uses the closest point on an effector object's
surface as the effector point.
- "Every Point" uses every point in a mesh effector object
as an effector point.
- The falloff is calculated from this point, so for example
with "surface" shape and "use only negative z axis" it's
possible to apply force only "inside" the effector object.
* Spherical effector is now renamed as "force" as it's no longer
just spherical.
* New effector parameter "flow", which makes the effector act as
surrounding air velocity, so the resulting force is
proportional to the velocity difference of the point and "air
velocity". For example a wind field with flow=1.0 results in
proper non-accelerating wind.
* New effector fields "turbulence", which creates nice random
flow paths, and "drag", which slows the points down.
* Much improved vortex field.
* Effectors can now effect particle rotation as well as location.
* Use full, or only positive/negative z-axis to apply force
(note. the z-axis is the surface normal in the case of
effector shape "surface")
* New "force field" submenu in add menu, which adds an empty
with the chosen effector (curve object for corve guides).
* Other dynamics should be quite easy to add to the effector
system too if wanted.
* "Unified" doesn't mean that force fields give the exact same results for
particles, softbody & cloth, since their final effect depends on many external
factors, like for example the surface area of the effected faces.
Code changes
* Subversion bump for correct handling of global gravity.
* Separate ui py file for common dynamics stuff.
* Particle settings updating is flushed with it's id through
DAG_id_flush_update(..).
Known issues
* Curve guides don't yet have all ui buttons in place, but they
should work none the less.
* Hair dynamics don't yet respect force fields.
Other changes
* Particle emission defaults now to frames 1-200 with life of 50
frames to fill the whole default timeline.
* Many particles drawing related crashes fixed.
* Sometimes particles didn't update on first frame properly.
* Hair with object/group visualization didn't work properly.
* Memory leaks with PointCacheID lists (Genscher, remember to
free pidlists after use :).
2009-09-30 22:10:14 +00:00
|
|
|
return;
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
for (a=0, bp=sb->bpoint; a<numVerts; a++, bp++) {
|
2010-06-14 23:56:12 +00:00
|
|
|
/* store where goals are now */
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->origS, bp->origE);
|
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
|
|
|
/* copy the position of the goals at desired end time */
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->origE, vertexCos[a]);
|
2009-09-10 22:32:33 +00:00
|
|
|
/* vertexCos came from local world, go global */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, bp->origE);
|
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
|
|
|
/* just to be save give bp->origT a defined value
|
2012-07-26 17:41:09 +00:00
|
|
|
* will be calculated in interpolate_exciter() */
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->origT, bp->origE);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-25 23:54:21 +00:00
|
|
|
|
2009-11-21 22:45:25 +00:00
|
|
|
/* void SB_estimate_transform */
|
2012-04-29 15:47:02 +00:00
|
|
|
/* input Object *ob out (says any object that can do SB like mesh, lattice, curve )
|
|
|
|
* output float lloc[3], float lrot[3][3], float lscale[3][3]
|
2012-03-09 18:28:30 +00:00
|
|
|
* that is:
|
|
|
|
* a precise position vector denoting the motion of the center of mass
|
|
|
|
* give a rotation/scale matrix using averaging method, that's why estimate and not calculate
|
2012-07-16 23:23:33 +00:00
|
|
|
* see: this is kind of reverse engineering: having to states of a point cloud and recover what happend
|
2012-03-09 18:28:30 +00:00
|
|
|
* our advantage here we know the identity of the vertex
|
|
|
|
* there are others methods giving other results.
|
2012-04-29 15:47:02 +00:00
|
|
|
* lloc, lrot, lscale are allowed to be NULL, just in case you don't need it.
|
2012-03-09 18:28:30 +00:00
|
|
|
* should be pretty useful for pythoneers :)
|
|
|
|
* not! velocity .. 2nd order stuff
|
2017-10-06 21:05:34 +11:00
|
|
|
* vcloud_estimate_transform_v3 see
|
2012-03-09 18:28:30 +00:00
|
|
|
*/
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
void SB_estimate_transform(Object *ob, float lloc[3], float lrot[3][3], float lscale[3][3])
|
2009-11-21 22:45:25 +00:00
|
|
|
{
|
|
|
|
BodyPoint *bp;
|
|
|
|
ReferenceVert *rp;
|
2011-02-13 10:52:18 +00:00
|
|
|
SoftBody *sb = NULL;
|
2009-11-25 23:54:21 +00:00
|
|
|
float (*opos)[3];
|
|
|
|
float (*rpos)[3];
|
2012-04-29 15:47:02 +00:00
|
|
|
float com[3], rcom[3];
|
2009-11-25 23:54:21 +00:00
|
|
|
int a;
|
2009-11-21 22:45:25 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (!ob ||!ob->soft) return; /* why did we get here ? */
|
2009-11-21 22:45:25 +00:00
|
|
|
sb= ob->soft;
|
2012-02-23 02:17:50 +00:00
|
|
|
if (!sb || !sb->bpoint) return;
|
2012-04-29 17:11:40 +00:00
|
|
|
opos= MEM_callocN((sb->totpoint)*3*sizeof(float), "SB_OPOS");
|
|
|
|
rpos= MEM_callocN((sb->totpoint)*3*sizeof(float), "SB_RPOS");
|
2010-06-14 23:56:12 +00:00
|
|
|
/* might filter vertex selection with a vertex group */
|
2012-02-23 02:17:50 +00:00
|
|
|
for (a=0, bp=sb->bpoint, rp=sb->scratch->Ref.ivert; a<sb->totpoint; a++, bp++, rp++) {
|
2012-04-29 15:47:02 +00:00
|
|
|
copy_v3_v3(rpos[a], rp->pos);
|
|
|
|
copy_v3_v3(opos[a], bp->pos);
|
2009-11-21 22:45:25 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 21:05:34 +11:00
|
|
|
vcloud_estimate_transform_v3(sb->totpoint, opos, NULL, rpos, NULL, com, rcom, lrot, lscale);
|
2012-04-29 15:47:02 +00:00
|
|
|
//sub_v3_v3(com, rcom);
|
|
|
|
if (lloc) copy_v3_v3(lloc, com);
|
|
|
|
copy_v3_v3(sb->lcom, com);
|
|
|
|
if (lscale) copy_m3_m3(sb->lscale, lscale);
|
|
|
|
if (lrot) copy_m3_m3(sb->lrot, lrot);
|
2009-11-25 23:54:21 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2009-11-25 23:54:21 +00:00
|
|
|
MEM_freeN(opos);
|
|
|
|
MEM_freeN(rpos);
|
2009-11-21 22:45:25 +00:00
|
|
|
}
|
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int numVerts)
|
|
|
|
{
|
|
|
|
BodyPoint *bp;
|
|
|
|
int a;
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
for (a=0, bp=sb->bpoint; a<numVerts; a++, bp++) {
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->pos, vertexCos[a]);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(ob->obmat, bp->pos); /* yep, sofbody is global coords*/
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->origS, bp->pos);
|
|
|
|
copy_v3_v3(bp->origE, bp->pos);
|
|
|
|
copy_v3_v3(bp->origT, bp->pos);
|
2012-10-22 08:15:51 +00:00
|
|
|
bp->vec[0] = bp->vec[1] = bp->vec[2] = 0.0f;
|
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
|
|
|
|
|
|
|
/* the bp->prev*'s are for rolling back from a canceled try to propagate in time
|
2012-03-03 20:19:11 +00:00
|
|
|
* adaptive step size algo in a nutshell:
|
2012-03-09 00:41:09 +00:00
|
|
|
* 1. set scheduled time step to new dtime
|
|
|
|
* 2. try to advance the scheduled time step, being optimistic execute it
|
2012-03-03 20:19:11 +00:00
|
|
|
* 3. check for success
|
2012-03-09 00:41:09 +00:00
|
|
|
* 3.a we 're fine continue, may be we can increase scheduled time again ?? if so, do so!
|
|
|
|
* 3.b we did exceed error limit --> roll back, shorten the scheduled time and try again at 2.
|
2012-03-03 20:19:11 +00:00
|
|
|
* 4. check if we did reach dtime
|
|
|
|
* 4.a nope we need to do some more at 2.
|
|
|
|
* 4.b yup we're done
|
|
|
|
*/
|
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
|
|
|
|
2011-11-06 16:38:21 +00:00
|
|
|
copy_v3_v3(bp->prevpos, bp->pos);
|
|
|
|
copy_v3_v3(bp->prevvec, bp->vec);
|
|
|
|
copy_v3_v3(bp->prevdx, bp->vec);
|
|
|
|
copy_v3_v3(bp->prevdv, bp->vec);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* make a nice clean scratch struc */
|
|
|
|
free_scratch(sb); /* clear if any */
|
|
|
|
sb_new_scratch(sb); /* make a new */
|
2010-06-14 23:56:12 +00:00
|
|
|
sb->scratch->needstobuildcollider=1;
|
2009-12-28 00:07:24 +00:00
|
|
|
zero_v3(sb->lcom);
|
|
|
|
unit_m3(sb->lrot);
|
|
|
|
unit_m3(sb->lscale);
|
|
|
|
|
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
/* copy some info to scratch */
|
2009-12-28 00:07:24 +00:00
|
|
|
/* we only need that if we want to reconstruct IPO */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (1) {
|
2009-12-28 00:07:24 +00:00
|
|
|
reference_to_scratch(ob);
|
2012-04-29 15:47:02 +00:00
|
|
|
SB_estimate_transform(ob, NULL, NULL, NULL);
|
|
|
|
SB_estimate_transform(ob, NULL, NULL, NULL);
|
2009-12-28 00:07:24 +00:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ob->type) {
|
2018-04-16 17:08:27 +02:00
|
|
|
case OB_MESH:
|
|
|
|
if (ob->softflag & OB_SB_FACECOLL) mesh_faces_to_scratch(ob);
|
|
|
|
break;
|
|
|
|
case OB_LATTICE:
|
|
|
|
break;
|
|
|
|
case OB_CURVE:
|
|
|
|
case OB_SURF:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-08-16 22:58:31 +00:00
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void softbody_step(struct Depsgraph *depsgraph, Scene *scene, Object *ob, SoftBody *sb, float dtime)
|
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
|
|
|
{
|
|
|
|
/* the simulator */
|
|
|
|
float forcetime;
|
2012-04-29 15:47:02 +00:00
|
|
|
double sct, sst;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
|
|
|
|
2009-11-02 23:42:08 +00:00
|
|
|
sst=PIL_check_seconds_timer();
|
2010-06-14 23:56:12 +00:00
|
|
|
/* Integration back in time is possible in theory, but pretty useless here.
|
2012-09-26 20:05:38 +00:00
|
|
|
* So we refuse to do so. Since we do not know anything about 'outside' changes
|
2012-03-03 20:19:11 +00:00
|
|
|
* especially colliders we refuse to go more than 10 frames.
|
|
|
|
*/
|
2012-02-23 02:17:50 +00:00
|
|
|
if (dtime < 0 || dtime > 10.5f) return;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2018-06-08 19:26:46 +02:00
|
|
|
ccd_update_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash);
|
2005-04-02 19:52:32 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch->needstobuildcollider) {
|
2018-06-08 19:26:46 +02:00
|
|
|
if (query_external_colliders(depsgraph, sb->collision_group)) {
|
|
|
|
ccd_build_deflector_hash(depsgraph, sb->collision_group, ob, sb->scratch->colliderhash);
|
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
|
|
|
}
|
|
|
|
sb->scratch->needstobuildcollider=0;
|
2005-08-16 22:58:31 +00:00
|
|
|
}
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2010-06-14 23:56:12 +00:00
|
|
|
if (sb->solver_ID < 2) {
|
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
|
|
|
/* special case of 2nd order Runge-Kutta type AKA Heun */
|
|
|
|
int mid_flags=0;
|
|
|
|
float err = 0;
|
2009-11-02 23:42:08 +00:00
|
|
|
float forcetimemax = 1.0f; /* set defaults guess we shall do one frame */
|
|
|
|
float forcetimemin = 0.01f; /* set defaults guess 1/100 is tight enough */
|
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
|
|
|
float timedone =0.0; /* how far did we get without violating error condition */
|
2012-03-03 20:19:11 +00:00
|
|
|
/* loops = counter for emergency brake
|
|
|
|
* we don't want to lock up the system if physics fail */
|
2012-02-27 10:35:39 +00:00
|
|
|
int loops = 0;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
SoftHeunTol = sb->rklimit; /* humm .. this should be calculated from sb parameters and sizes */
|
2009-11-02 23:42:08 +00:00
|
|
|
/* adjust loop limits */
|
|
|
|
if (sb->minloops > 0) forcetimemax = dtime / sb->minloops;
|
|
|
|
if (sb->maxloops > 0) forcetimemin = dtime / sb->maxloops;
|
2005-04-02 19:52:32 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->solver_ID>0) mid_flags |= MID_PRESERVE;
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-23 02:17:50 +00:00
|
|
|
forcetime = forcetimemax; /* hope for integrating in one step */
|
2012-04-28 06:31:57 +00:00
|
|
|
while ( (ABS(timedone) < ABS(dtime)) && (loops < 2000) ) {
|
2010-06-14 23:56:12 +00:00
|
|
|
/* set goals in time */
|
2012-04-29 15:47:02 +00:00
|
|
|
interpolate_exciter(ob, 200, (int)(200.0f*(timedone/dtime)));
|
2010-06-14 23:56:12 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
sb->scratch->flag &= ~SBF_DOFUZZY;
|
|
|
|
/* do predictive euler step */
|
2018-04-06 12:07:27 +02:00
|
|
|
softbody_calc_forces(depsgraph, scene, ob, forcetime, timedone/dtime);
|
2006-11-10 23:09:16 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
softbody_apply_forces(ob, forcetime, 1, NULL, mid_flags);
|
2005-05-02 13:28:13 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
/* crop new slope values to do averaged slope step */
|
2018-04-06 12:07:27 +02:00
|
|
|
softbody_calc_forces(depsgraph, scene, ob, forcetime, timedone/dtime);
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
softbody_apply_forces(ob, forcetime, 2, &err, mid_flags);
|
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
|
|
|
softbody_apply_goalsnap(ob);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
if (err > SoftHeunTol) { /* error needs to be scaled to some quantity */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (forcetime > forcetimemin) {
|
2013-12-01 12:37:05 +11:00
|
|
|
forcetime = max_ff(forcetime / 2.0f, forcetimemin);
|
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
|
|
|
softbody_restore_prev_step(ob);
|
2012-04-29 15:47:02 +00:00
|
|
|
//printf("down, ");
|
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
|
|
|
}
|
|
|
|
else {
|
|
|
|
timedone += forcetime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float newtime = forcetime * 1.1f; /* hope for 1.1 times better conditions in next step */
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->scratch->flag & SBF_DOFUZZY) {
|
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
|
|
|
//if (err > SoftHeunTol/(2.0f*sb->fuzzyness)) { /* stay with this stepsize unless err really small */
|
|
|
|
newtime = forcetime;
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (err > SoftHeunTol/2.0f) { /* stay with this stepsize unless err really small */
|
|
|
|
newtime = forcetime;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timedone += forcetime;
|
2013-12-01 12:37:05 +11:00
|
|
|
newtime = min_ff(forcetimemax, max_ff(newtime, forcetimemin));
|
2012-04-29 15:47:02 +00:00
|
|
|
//if (newtime > forcetime) printf("up, ");
|
2011-11-11 12:00:08 +00:00
|
|
|
if (forcetime > 0.0f)
|
2013-12-01 12:37:05 +11:00
|
|
|
forcetime = min_ff(dtime - timedone, newtime);
|
2010-06-14 23:56:12 +00:00
|
|
|
else
|
2013-12-01 12:37:05 +11:00
|
|
|
forcetime = max_ff(dtime - timedone, newtime);
|
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
|
|
|
}
|
|
|
|
loops++;
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->solverflags & SBSO_MONITOR ) {
|
2012-11-04 07:18:29 +00:00
|
|
|
sct = PIL_check_seconds_timer();
|
|
|
|
if (sct - sst > 0.5) printf("%3.0f%% \r", 100.0f * timedone / dtime);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
/* ask for user break */
|
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
|
|
|
if (SB_localInterruptCallBack && SB_localInterruptCallBack()) break;
|
2005-08-15 10:30:53 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
|
|
|
/* move snapped to final position */
|
|
|
|
interpolate_exciter(ob, 2, 2);
|
|
|
|
softbody_apply_goalsnap(ob);
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2012-03-31 00:59:17 +00:00
|
|
|
// if (G.debug & G_DEBUG) {
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->solverflags & SBSO_MONITOR ) {
|
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
|
|
|
if (loops > HEUNWARNLIMIT) /* monitor high loop counts */
|
2012-04-29 15:47:02 +00:00
|
|
|
printf("\r needed %d steps/frame", loops);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
2010-06-14 23:56:12 +00:00
|
|
|
|
2005-01-12 22:28:13 +00:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
else if (sb->solver_ID == 2) {
|
|
|
|
/* do semi "fake" implicit euler */
|
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
|
|
|
//removed
|
|
|
|
}/*SOLVER SELECT*/
|
2012-04-28 06:31:57 +00:00
|
|
|
else if (sb->solver_ID == 4) {
|
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
|
|
|
/* do semi "fake" implicit euler */
|
|
|
|
}/*SOLVER SELECT*/
|
2012-02-27 10:35:39 +00:00
|
|
|
else if (sb->solver_ID == 3) {
|
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
|
|
|
/* do "stupid" semi "fake" implicit euler */
|
|
|
|
//removed
|
2005-08-15 10:30:53 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}/*SOLVER SELECT*/
|
2012-03-24 06:18:31 +00:00
|
|
|
else {
|
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
|
|
|
printf("softbody no valid solver ID!");
|
|
|
|
}/*SOLVER SELECT*/
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->plastic) { apply_spring_memory(ob);}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2012-02-27 10:35:39 +00:00
|
|
|
if (sb->solverflags & SBSO_MONITOR ) {
|
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
|
|
|
sct=PIL_check_seconds_timer();
|
2012-11-04 07:18:29 +00:00
|
|
|
if ((sct - sst > 0.5) || (G.debug & G_DEBUG)) printf(" solver time %f sec %s\n", sct-sst, ob->id.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
|
|
|
}
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
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
|
|
|
/* simulates one step. framenr is in frames */
|
2018-04-06 12:07:27 +02:00
|
|
|
void sbObjectStep(struct Depsgraph *depsgraph, Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], int numVerts)
|
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
|
|
|
{
|
|
|
|
SoftBody *sb= ob->soft;
|
2016-12-28 17:30:58 +01:00
|
|
|
PointCache *cache;
|
|
|
|
PTCacheID pid;
|
|
|
|
float dtime, timescale;
|
|
|
|
int framedelta, framenr, startframe, endframe;
|
|
|
|
int cache_result;
|
|
|
|
cache= sb->pointcache;
|
|
|
|
|
|
|
|
framenr= (int)cfra;
|
|
|
|
framedelta= framenr - cache->simframe;
|
|
|
|
|
|
|
|
BKE_ptcache_id_from_softbody(&pid, ob, sb);
|
|
|
|
BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale);
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
/* check for changes in mesh, should only happen in case the mesh
|
|
|
|
* structure changes during an animation */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->bpoint && numVerts != sb->totpoint) {
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_invalidate(cache);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
return;
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
2006-11-10 23:09:16 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
/* clamp frame ranges */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (framenr < startframe) {
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_invalidate(cache);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
else if (framenr > endframe) {
|
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
|
|
|
framenr = endframe;
|
|
|
|
}
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
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
|
|
|
/* verify if we need to create the softbody data */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->bpoint == NULL ||
|
2012-05-20 19:49:27 +00:00
|
|
|
((ob->softflag & OB_SB_EDGES) && !ob->soft->bspring && object_has_edges(ob)))
|
|
|
|
{
|
Particles
=========
Merge of the famous particle patch by Janne Karhu, a full rewrite
of the Blender particle system. This includes:
- Emitter, Hair and Reactor particle types.
- Newtonian, Keyed and Boids physics.
- Various particle visualisation and rendering types.
- Vertex group and texture control for various properties.
- Interpolated child particles from parents.
- Hair editing with combing, growing, cutting, .. .
- Explode modifier.
- Harmonic, Magnetic fields, and multiple falloff types.
.. and lots of other things, some more info is here:
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite
http://wiki.blender.org/index.php/BlenderDev/Particles_Rewrite_Doc
The new particle system cannot be backwards compatible. Old particle
systems are being converted to the new system, but will require
tweaking to get them looking the same as before.
Point Cache
===========
The new system to replace manual baking, based on automatic caching
on disk. This is currently used by softbodies and the particle system.
See the Cache API section on:
http://wiki.blender.org/index.php/BlenderDev/PhysicsSprint
Documentation
=============
These new features still need good docs for the release logs, help
for this is appreciated.
2007-11-26 22:09:57 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ob->type) {
|
2009-09-10 22:32:33 +00:00
|
|
|
case OB_MESH:
|
|
|
|
mesh_to_softbody(scene, ob);
|
|
|
|
break;
|
|
|
|
case OB_LATTICE:
|
|
|
|
lattice_to_softbody(scene, ob);
|
|
|
|
break;
|
|
|
|
case OB_CURVE:
|
|
|
|
case OB_SURF:
|
|
|
|
curve_surf_to_softbody(scene, ob);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
renew_softbody(scene, ob, numVerts, 0);
|
|
|
|
break;
|
2006-11-10 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
|
|
|
softbody_reset(ob, sb, vertexCos, numVerts);
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
2006-01-31 22:48:41 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
/* still no points? go away */
|
2012-02-23 02:17:50 +00:00
|
|
|
if (sb->totpoint==0) {
|
2009-11-21 22:45:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-02-23 02:17:50 +00:00
|
|
|
if (framenr == startframe) {
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
|
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
/* first frame, no simulation to do, just set the positions */
|
|
|
|
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_validate(cache, framenr);
|
|
|
|
cache->flag &= ~PTCACHE_REDO_NEEDED;
|
|
|
|
|
2012-01-09 14:08:06 +00:00
|
|
|
sb->last_frame = framenr;
|
|
|
|
|
2009-09-04 23:06:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* try to read from cache */
|
2016-12-28 17:30:58 +01:00
|
|
|
bool can_simulate = (framenr == sb->last_frame + 1) && !(cache->flag & PTCACHE_BAKED);
|
|
|
|
|
|
|
|
cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, can_simulate);
|
|
|
|
|
|
|
|
if (cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED ||
|
2018-04-16 18:13:48 +02:00
|
|
|
(!can_simulate && cache_result == PTCACHE_READ_OLD))
|
|
|
|
{
|
2016-12-28 17:30:58 +01:00
|
|
|
softbody_to_object(ob, vertexCos, numVerts, sb->local);
|
|
|
|
|
|
|
|
BKE_ptcache_validate(cache, framenr);
|
|
|
|
|
|
|
|
if (cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED)
|
|
|
|
BKE_ptcache_write(&pid, framenr);
|
|
|
|
|
|
|
|
sb->last_frame = framenr;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (cache_result==PTCACHE_READ_OLD) {
|
|
|
|
; /* do nothing */
|
|
|
|
}
|
|
|
|
else if (/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */
|
|
|
|
/* if baked and nothing in cache, do nothing */
|
|
|
|
BKE_ptcache_invalidate(cache);
|
|
|
|
return;
|
|
|
|
}
|
2005-04-04 18:09:47 +00:00
|
|
|
|
2016-08-11 13:36:29 +03:00
|
|
|
if (!can_simulate)
|
2012-01-09 14:08:06 +00:00
|
|
|
return;
|
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
/* if on second frame, write cache for first frame */
|
|
|
|
if (cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0))
|
|
|
|
BKE_ptcache_write(&pid, startframe);
|
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
softbody_update_positions(ob, sb, vertexCos, numVerts);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
/* checking time: */
|
|
|
|
dtime = framedelta*timescale;
|
2005-04-04 18:09:47 +00:00
|
|
|
|
2009-11-04 00:21:25 +00:00
|
|
|
/* do simulation */
|
2018-04-06 12:07:27 +02:00
|
|
|
softbody_step(depsgraph, scene, ob, sb, dtime);
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2009-09-10 22:32:33 +00:00
|
|
|
softbody_to_object(ob, vertexCos, numVerts, 0);
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
BKE_ptcache_validate(cache, framenr);
|
|
|
|
BKE_ptcache_write(&pid, framenr);
|
|
|
|
|
2012-01-09 14:08:06 +00:00
|
|
|
sb->last_frame = framenr;
|
2004-10-01 14:10:30 +00:00
|
|
|
}
|
|
|
|
|