2007-10-18 23:12:30 +00:00
|
|
|
/* cloth.c
|
|
|
|
|
*
|
2007-09-16 16:23:21 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2007-09-16 16:23:21 +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-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2007-09-16 16:23:21 +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,
|
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) Blender Foundation
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
2008-02-26 09:55:07 +00:00
|
|
|
* Contributor(s): Daniel Genrich
|
2007-09-16 16:23:21 +00:00
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2007-09-16 16:23:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2008-03-13 22:45:36 +00:00
|
|
|
#include "BKE_cloth.h"
|
|
|
|
|
|
2008-01-07 03:20:43 +00:00
|
|
|
#include "DNA_cloth_types.h"
|
2007-09-16 16:23:21 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
#include "DNA_object_force.h"
|
2007-11-06 12:08:39 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
#include "BKE_deform.h"
|
|
|
|
|
#include "BKE_DerivedMesh.h"
|
|
|
|
|
#include "BKE_cdderivedmesh.h"
|
|
|
|
|
#include "BKE_effect.h"
|
|
|
|
|
#include "BKE_global.h"
|
2007-11-06 12:08:39 +00:00
|
|
|
#include "BKE_object.h"
|
2008-01-07 03:20:43 +00:00
|
|
|
#include "BKE_modifier.h"
|
2007-09-16 16:23:21 +00:00
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
2008-01-07 03:20:43 +00:00
|
|
|
#include "BKE_pointcache.h"
|
2007-12-18 16:54:12 +00:00
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
#include "BLI_kdopbvh.h"
|
|
|
|
|
|
2008-05-14 16:09:56 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
#ifdef _WIN32
|
2007-10-18 23:12:30 +00:00
|
|
|
void tstart ( void )
|
|
|
|
|
{}
|
|
|
|
|
void tend ( void )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
double tval()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
#include <sys/time.h>
|
2008-01-29 21:01:12 +00:00
|
|
|
static struct timeval _tstart, _tend;
|
|
|
|
|
static struct timezone tz;
|
|
|
|
|
void tstart ( void )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2007-10-18 23:12:30 +00:00
|
|
|
gettimeofday ( &_tstart, &tz );
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2007-10-18 23:12:30 +00:00
|
|
|
void tend ( void )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2007-10-18 23:12:30 +00:00
|
|
|
gettimeofday ( &_tend,&tz );
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
double tval()
|
|
|
|
|
{
|
|
|
|
|
double t1, t2;
|
2007-10-18 23:12:30 +00:00
|
|
|
t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 );
|
|
|
|
|
t2 = ( double ) _tend.tv_sec + ( double ) _tend.tv_usec/ ( 1000*1000 );
|
2007-09-16 16:23:21 +00:00
|
|
|
return t2-t1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2008-05-14 16:09:56 +00:00
|
|
|
|
|
|
|
|
/* Util macros */
|
|
|
|
|
#define TO_STR(a) #a
|
|
|
|
|
#define JOIN(a,b) a##b
|
|
|
|
|
|
|
|
|
|
/* Benchmark macros */
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
|
|
#define BENCH(a) \
|
|
|
|
|
do { \
|
|
|
|
|
clock_t _clock_init = clock(); \
|
|
|
|
|
(a); \
|
|
|
|
|
printf("%s: %fms\n", #a, (float)(clock()-_clock_init)*1000/CLOCKS_PER_SEC); \
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
#define BENCH_VAR(name) clock_t JOIN(_bench_step,name) = 0, JOIN(_bench_total,name) = 0
|
|
|
|
|
#define BENCH_BEGIN(name) JOIN(_bench_step, name) = clock()
|
|
|
|
|
#define BENCH_END(name) JOIN(_bench_total,name) += clock() - JOIN(_bench_step,name)
|
|
|
|
|
#define BENCH_RESET(name) JOIN(_bench_total, name) = 0
|
|
|
|
|
#define BENCH_REPORT(name) printf("%s: %fms\n", TO_STR(name), JOIN(_bench_total,name)*1000.0f/CLOCKS_PER_SEC)
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#define BENCH(a) (a)
|
|
|
|
|
#define BENCH_VAR(name)
|
|
|
|
|
#define BENCH_BEGIN(name)
|
|
|
|
|
#define BENCH_END(name)
|
|
|
|
|
#define BENCH_RESET(name)
|
|
|
|
|
#define BENCH_REPORT(name)
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
/* Our available solvers. */
|
|
|
|
|
// 255 is the magic reserved number, so NEVER try to put 255 solvers in here!
|
|
|
|
|
// 254 = MAX!
|
2008-01-07 03:20:43 +00:00
|
|
|
static CM_SOLVER_DEF solvers [] =
|
2008-01-29 21:01:12 +00:00
|
|
|
{
|
|
|
|
|
{ "Implicit", CM_IMPLICIT, implicit_init, implicit_solver, implicit_free },
|
2008-01-07 03:20:43 +00:00
|
|
|
// { "Implicit C++", CM_IMPLICITCPP, implicitcpp_init, implicitcpp_solver, implicitcpp_free },
|
2008-01-29 21:01:12 +00:00
|
|
|
};
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
/* ********** cloth engine ******* */
|
|
|
|
|
/* Prototypes for internal functions.
|
|
|
|
|
*/
|
2008-01-24 10:43:12 +00:00
|
|
|
static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *dm);
|
2008-01-07 03:20:43 +00:00
|
|
|
static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm );
|
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 int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first);
|
2008-01-23 13:24:44 +00:00
|
|
|
int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm );
|
2008-01-29 02:24:37 +00:00
|
|
|
static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm );
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2007-10-26 10:46:40 +00:00
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* External interface called by modifier.c clothModifier functions.
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
/**
|
2008-01-29 21:01:12 +00:00
|
|
|
* cloth_init - creates a new cloth simulation.
|
|
|
|
|
*
|
|
|
|
|
* 1. create object
|
|
|
|
|
* 2. fill object with standard values or with the GUI settings if given
|
|
|
|
|
*/
|
2008-01-07 03:20:43 +00:00
|
|
|
void cloth_init ( ClothModifierData *clmd )
|
2008-01-22 20:28:12 +00:00
|
|
|
{
|
2007-09-16 16:23:21 +00:00
|
|
|
/* Initialize our new data structure to reasonable values. */
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->gravity [0] = 0.0;
|
|
|
|
|
clmd->sim_parms->gravity [1] = 0.0;
|
|
|
|
|
clmd->sim_parms->gravity [2] = -9.81;
|
2008-03-12 10:41:47 +00:00
|
|
|
clmd->sim_parms->structural = 15.0;
|
|
|
|
|
clmd->sim_parms->shear = 15.0;
|
|
|
|
|
clmd->sim_parms->bending = 0.5;
|
|
|
|
|
clmd->sim_parms->Cdis = 5.0;
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->Cvi = 1.0;
|
2008-03-12 10:41:47 +00:00
|
|
|
clmd->sim_parms->mass = 0.3f;
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->stepsPerFrame = 5;
|
2008-01-29 16:32:42 +00:00
|
|
|
clmd->sim_parms->flags = 0;
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->solver_type = 0;
|
|
|
|
|
clmd->sim_parms->preroll = 0;
|
|
|
|
|
clmd->sim_parms->maxspringlen = 10;
|
|
|
|
|
clmd->sim_parms->vgroup_mass = 0;
|
2008-02-12 11:04:58 +00:00
|
|
|
clmd->sim_parms->avg_spring_len = 0.0;
|
2008-02-28 00:01:19 +00:00
|
|
|
clmd->sim_parms->presets = 2; /* cotton as start setting */
|
2008-04-09 16:38:26 +00:00
|
|
|
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
|
2008-01-23 15:30:23 +00:00
|
|
|
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->coll_parms->self_friction = 5.0;
|
2008-02-03 22:37:43 +00:00
|
|
|
clmd->coll_parms->friction = 5.0;
|
2008-01-29 02:24:37 +00:00
|
|
|
clmd->coll_parms->loop_count = 3;
|
|
|
|
|
clmd->coll_parms->epsilon = 0.015f;
|
2008-01-25 08:55:27 +00:00
|
|
|
clmd->coll_parms->flags = CLOTH_COLLSETTINGS_FLAG_ENABLED;
|
2008-02-11 13:30:52 +00:00
|
|
|
clmd->coll_parms->collision_list = NULL;
|
2008-02-12 11:04:58 +00:00
|
|
|
clmd->coll_parms->self_loop_count = 1.0;
|
|
|
|
|
clmd->coll_parms->selfepsilon = 0.75;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
/* These defaults are copied from softbody.c's
|
|
|
|
|
* softbody_calc_forces() function.
|
|
|
|
|
*/
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->eff_force_scale = 1000.0;
|
|
|
|
|
clmd->sim_parms->eff_wind_scale = 250.0;
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
// also from softbodies
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->maxgoal = 1.0f;
|
|
|
|
|
clmd->sim_parms->mingoal = 0.0f;
|
|
|
|
|
clmd->sim_parms->defgoal = 0.0f;
|
2008-02-27 03:23:17 +00:00
|
|
|
clmd->sim_parms->goalspring = 1.0f;
|
2008-01-22 20:28:12 +00:00
|
|
|
clmd->sim_parms->goalfrict = 0.0f;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
BVHTree *bvhtree_build_from_cloth (ClothModifierData *clmd, float epsilon)
|
2008-01-21 02:23:03 +00:00
|
|
|
{
|
2008-05-07 20:42:16 +00:00
|
|
|
int i;
|
|
|
|
|
BVHTree *bvhtree;
|
2008-01-21 02:23:03 +00:00
|
|
|
Cloth *cloth = clmd->clothObject;
|
2008-05-07 20:42:16 +00:00
|
|
|
ClothVertex *verts;
|
|
|
|
|
MFace *mfaces;
|
|
|
|
|
float co[12];
|
2008-01-21 02:23:03 +00:00
|
|
|
|
|
|
|
|
if(!clmd)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
cloth = clmd->clothObject;
|
|
|
|
|
|
|
|
|
|
if(!cloth)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
verts = cloth->verts;
|
2008-05-07 20:42:16 +00:00
|
|
|
mfaces = cloth->mfaces;
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-02-05 15:09:48 +00:00
|
|
|
// in the moment, return zero if no faces there
|
|
|
|
|
if(!cloth->numfaces)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
// create quadtree with k=26
|
2008-05-14 16:09:56 +00:00
|
|
|
bvhtree = BLI_bvhtree_new(cloth->numfaces, epsilon, 8, 6);
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
// fill tree
|
|
|
|
|
for(i = 0; i < cloth->numfaces; i++, mfaces++)
|
2008-01-21 02:23:03 +00:00
|
|
|
{
|
2008-05-07 20:42:16 +00:00
|
|
|
VECCOPY(&co[0*3], verts[mfaces->v1].xold);
|
|
|
|
|
VECCOPY(&co[1*3], verts[mfaces->v2].xold);
|
|
|
|
|
VECCOPY(&co[2*3], verts[mfaces->v3].xold);
|
|
|
|
|
|
|
|
|
|
if(mfaces->v4)
|
|
|
|
|
VECCOPY(&co[3*3], verts[mfaces->v4].xold);
|
|
|
|
|
|
|
|
|
|
BLI_bvhtree_insert(bvhtree, i, co, (mfaces->v4 ? 4 : 3));
|
2008-01-21 02:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
// balance tree
|
|
|
|
|
BLI_bvhtree_balance(bvhtree);
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
return bvhtree;
|
2008-01-21 02:23:03 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
void bvhtree_update_from_cloth(ClothModifierData *clmd, int moving)
|
|
|
|
|
{
|
2008-01-21 02:23:03 +00:00
|
|
|
unsigned int i = 0;
|
|
|
|
|
Cloth *cloth = clmd->clothObject;
|
2008-05-07 20:42:16 +00:00
|
|
|
BVHTree *bvhtree = cloth->bvhtree;
|
2008-01-21 02:23:03 +00:00
|
|
|
ClothVertex *verts = cloth->verts;
|
2008-05-07 20:42:16 +00:00
|
|
|
MFace *mfaces;
|
|
|
|
|
float co[12], co_moving[12];
|
|
|
|
|
int ret = 0;
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
if(!bvhtree)
|
2008-01-21 02:23:03 +00:00
|
|
|
return;
|
|
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
mfaces = cloth->mfaces;
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-05-07 20:42:16 +00:00
|
|
|
// update vertex position in bvh tree
|
|
|
|
|
if(verts && mfaces)
|
2008-01-21 02:23:03 +00:00
|
|
|
{
|
2008-05-07 20:42:16 +00:00
|
|
|
for(i = 0; i < cloth->numfaces; i++, mfaces++)
|
2008-01-21 02:23:03 +00:00
|
|
|
{
|
2008-05-07 20:42:16 +00:00
|
|
|
VECCOPY(&co[0*3], verts[mfaces->v1].txold);
|
|
|
|
|
VECCOPY(&co[1*3], verts[mfaces->v2].txold);
|
|
|
|
|
VECCOPY(&co[2*3], verts[mfaces->v3].txold);
|
|
|
|
|
|
|
|
|
|
if(mfaces->v4)
|
|
|
|
|
VECCOPY(&co[3*3], verts[mfaces->v4].txold);
|
|
|
|
|
|
|
|
|
|
// copy new locations into array
|
|
|
|
|
if(moving)
|
|
|
|
|
{
|
|
|
|
|
// update moving positions
|
|
|
|
|
VECCOPY(&co_moving[0*3], verts[mfaces->v1].tx);
|
|
|
|
|
VECCOPY(&co_moving[1*3], verts[mfaces->v2].tx);
|
|
|
|
|
VECCOPY(&co_moving[2*3], verts[mfaces->v3].tx);
|
|
|
|
|
|
|
|
|
|
if(mfaces->v4)
|
|
|
|
|
VECCOPY(&co_moving[3*3], verts[mfaces->v4].tx);
|
|
|
|
|
|
|
|
|
|
ret = BLI_bvhtree_update_node(bvhtree, i, co, co_moving, (mfaces->v4 ? 4 : 3));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ret = BLI_bvhtree_update_node(bvhtree, i, co, NULL, (mfaces->v4 ? 4 : 3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check if tree is already full
|
|
|
|
|
if(!ret)
|
|
|
|
|
break;
|
2008-01-21 02:23:03 +00:00
|
|
|
}
|
2008-05-07 20:42:16 +00:00
|
|
|
|
|
|
|
|
BLI_bvhtree_update_tree(bvhtree);
|
2008-01-21 02:23:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-06 12:08:39 +00:00
|
|
|
int modifiers_indexInObject(Object *ob, ModifierData *md_seek);
|
|
|
|
|
|
2008-01-25 10:33:19 +00:00
|
|
|
int cloth_read_cache(Object *ob, ClothModifierData *clmd, float framenr)
|
2007-11-06 12:08:39 +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
|
|
|
PTCacheID pid;
|
|
|
|
|
PTCacheFile *pf;
|
2007-11-06 12:08:39 +00:00
|
|
|
Cloth *cloth = clmd->clothObject;
|
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
|
|
|
unsigned int a, ret = 1;
|
2007-11-06 12:08:39 +00:00
|
|
|
|
|
|
|
|
if(!cloth)
|
|
|
|
|
return 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
|
|
|
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
|
|
|
|
|
pf = BKE_ptcache_file_open(&pid, PTCACHE_FILE_READ, framenr);
|
|
|
|
|
if(pf) {
|
|
|
|
|
for(a = 0; a < cloth->numverts; a++) {
|
|
|
|
|
if(!BKE_ptcache_file_read_floats(pf, cloth->verts[a].x, 3)) {
|
2007-11-06 12:08:39 +00:00
|
|
|
ret = 0;
|
|
|
|
|
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(!BKE_ptcache_file_read_floats(pf, cloth->verts[a].xconst, 3)) {
|
2007-11-06 12:08:39 +00:00
|
|
|
ret = 0;
|
|
|
|
|
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(!BKE_ptcache_file_read_floats(pf, cloth->verts[a].v, 3)) {
|
2007-11-06 12:08:39 +00:00
|
|
|
ret = 0;
|
|
|
|
|
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
|
|
|
BKE_ptcache_file_close(pf);
|
2008-01-29 02:24:37 +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
|
|
|
else
|
|
|
|
|
ret = 0;
|
2008-01-29 02:24:37 +00:00
|
|
|
|
2007-11-06 12:08:39 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-23 15:30:23 +00:00
|
|
|
void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
|
|
|
|
|
{
|
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
|
|
|
PTCacheID pid;
|
2008-01-29 02:24:37 +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
|
|
|
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
|
|
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
// don't do anything as long as we're in editmode!
|
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(pid.cache->flag & PTCACHE_BAKE_EDIT_ACTIVE)
|
2008-01-29 16:32:42 +00:00
|
|
|
return;
|
2008-01-29 02:24:37 +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
|
|
|
BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
|
2008-01-23 15:30:23 +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
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
void cloth_write_cache(Object *ob, ClothModifierData *clmd, float framenr)
|
2008-01-23 15:30:23 +00:00
|
|
|
{
|
|
|
|
|
Cloth *cloth = clmd->clothObject;
|
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
|
|
|
PTCacheID pid;
|
|
|
|
|
PTCacheFile *pf;
|
|
|
|
|
unsigned int a;
|
2008-01-29 02:24:37 +00:00
|
|
|
|
2008-01-23 15:30:23 +00:00
|
|
|
if(!cloth)
|
|
|
|
|
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
|
|
|
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
|
|
|
|
|
pf = BKE_ptcache_file_open(&pid, PTCACHE_FILE_WRITE, framenr);
|
|
|
|
|
if(!pf)
|
2008-01-23 15:30:23 +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
|
|
|
for(a = 0; a < cloth->numverts; a++) {
|
|
|
|
|
BKE_ptcache_file_write_floats(pf, cloth->verts[a].x, 3);
|
|
|
|
|
BKE_ptcache_file_write_floats(pf, cloth->verts[a].xconst, 3);
|
|
|
|
|
BKE_ptcache_file_write_floats(pf, cloth->verts[a].v, 3);
|
2008-01-23 15:30:23 +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
|
|
|
BKE_ptcache_file_close(pf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
|
|
|
|
|
{
|
|
|
|
|
PointCache *cache;
|
|
|
|
|
|
|
|
|
|
cache= clmd->point_cache;
|
|
|
|
|
|
|
|
|
|
/* initialize simulation data if it didn't exist already */
|
|
|
|
|
if(clmd->clothObject == NULL) {
|
|
|
|
|
if(!cloth_from_object(ob, clmd, result, framenr, 1)) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-01-23 15:30:23 +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(clmd->clothObject == NULL) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-01-29 16:32:42 +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
|
|
|
implicit_set_positions(clmd);
|
|
|
|
|
}
|
2008-01-29 02:24:37 +00:00
|
|
|
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
return 1;
|
2008-01-23 15:30:23 +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 int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *result, int framenr)
|
2008-01-29 21:01:12 +00:00
|
|
|
{
|
|
|
|
|
ClothVertex *verts = NULL;
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
Cloth *cloth;
|
|
|
|
|
ListBase *effectors = NULL;
|
|
|
|
|
MVert *mvert;
|
|
|
|
|
int i, ret = 0;
|
|
|
|
|
|
|
|
|
|
/* simulate 1 frame forward */
|
|
|
|
|
cloth = clmd->clothObject;
|
|
|
|
|
verts = cloth->verts;
|
|
|
|
|
mvert = result->getVertArray(result);
|
|
|
|
|
|
|
|
|
|
/* force any pinned verts to their constrained location. */
|
|
|
|
|
for(i = 0; i < clmd->clothObject->numverts; i++, verts++) {
|
|
|
|
|
/* save the previous position. */
|
|
|
|
|
VECCOPY(verts->xold, verts->xconst);
|
|
|
|
|
VECCOPY(verts->txold, verts->x);
|
2008-01-23 15:30:23 +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
|
|
|
/* Get the current position. */
|
|
|
|
|
VECCOPY(verts->xconst, mvert[i].co);
|
|
|
|
|
Mat4MulVecfl(ob->obmat, verts->xconst);
|
2008-01-29 21:01: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
|
|
|
tstart();
|
|
|
|
|
|
|
|
|
|
/* call the solver. */
|
|
|
|
|
if(solvers [clmd->sim_parms->solver_type].solver)
|
|
|
|
|
ret = solvers[clmd->sim_parms->solver_type].solver(ob, framenr, clmd, effectors);
|
|
|
|
|
|
|
|
|
|
tend();
|
|
|
|
|
|
2008-05-07 17:44:46 +00:00
|
|
|
printf ( "Cloth simulation time: %f\n", ( float ) tval() );
|
2008-01-29 21:01: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
|
|
|
return ret;
|
|
|
|
|
}
|
2007-12-18 16:54:12 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
/************************************************
|
|
|
|
|
* clothModifier_do - main simulation function
|
|
|
|
|
************************************************/
|
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
|
|
|
DerivedMesh *clothModifier_do(ClothModifierData *clmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
|
2007-09-16 16:23:21 +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
|
|
|
DerivedMesh *result;
|
|
|
|
|
PointCache *cache;
|
|
|
|
|
PTCacheID pid;
|
|
|
|
|
float timescale;
|
|
|
|
|
int framedelta, framenr, startframe, endframe;
|
|
|
|
|
|
|
|
|
|
framenr= (int)G.scene->r.cfra;
|
|
|
|
|
cache= clmd->point_cache;
|
2008-01-24 10:43:12 +00:00
|
|
|
result = CDDM_copy(dm);
|
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
|
|
|
|
|
|
|
|
BKE_ptcache_id_from_cloth(&pid, ob, clmd);
|
|
|
|
|
BKE_ptcache_id_time(&pid, framenr, &startframe, &endframe, ×cale);
|
|
|
|
|
clmd->sim_parms->timescale= timescale;
|
|
|
|
|
|
|
|
|
|
if(!result) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
2008-01-24 10:43:12 +00:00
|
|
|
return dm;
|
|
|
|
|
}
|
|
|
|
|
|
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 we still have the same number of vertices, if not do nothing.
|
|
|
|
|
* note that this should only happen if the number of vertices changes
|
|
|
|
|
* during an animation due to a preceding modifier, this should not
|
|
|
|
|
* happen because of object changes! */
|
|
|
|
|
if(clmd->clothObject) {
|
|
|
|
|
if(result->getNumVerts(result) != clmd->clothObject->numverts) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
2008-01-29 02:24:37 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-29 21:01:12 +00:00
|
|
|
// unused in the moment, calculated seperately in implicit.c
|
2008-04-09 16:38:26 +00:00
|
|
|
clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
|
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
|
|
|
|
|
|
|
|
/* handle continuous simulation with the play button */
|
|
|
|
|
if(BKE_ptcache_get_continue_physics()) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
|
|
|
|
|
|
|
|
|
/* do simulation */
|
|
|
|
|
if(!do_init_cloth(ob, clmd, result, framenr))
|
2008-01-29 21:01:12 +00:00
|
|
|
return result;
|
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_step_cloth(ob, clmd, result, framenr);
|
|
|
|
|
cloth_to_object(ob, clmd, result);
|
|
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
/* simulation is only active during a specific period */
|
|
|
|
|
if(framenr < startframe) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
2008-01-29 16:32:42 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
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 if(framenr > endframe) {
|
|
|
|
|
framenr= endframe;
|
2008-02-03 22:37:43 +00:00
|
|
|
}
|
2008-01-07 03:20:43 +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(cache->flag & PTCACHE_SIMULATION_VALID)
|
|
|
|
|
framedelta= framenr - cache->simframe;
|
|
|
|
|
else
|
|
|
|
|
framedelta= -1;
|
2008-01-07 03:20:43 +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
|
|
|
/* initialize simulation data if it didn't exist already */
|
|
|
|
|
if(!do_init_cloth(ob, clmd, result, framenr))
|
|
|
|
|
return result;
|
2008-01-07 03:20:43 +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
|
|
|
/* try to read from cache */
|
|
|
|
|
if(cloth_read_cache(ob, clmd, framenr)) {
|
|
|
|
|
cache->flag |= PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= framenr;
|
2008-01-07 03:20:43 +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
|
|
|
implicit_set_positions(clmd);
|
2008-01-29 02:24:37 +00:00
|
|
|
cloth_to_object (ob, clmd, result);
|
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 result;
|
2008-01-29 02:24:37 +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
|
|
|
else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) {
|
|
|
|
|
/* if baked and nothing in cache, do nothing */
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
|
|
|
|
return result;
|
2007-11-06 12:08:39 +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(framenr == startframe) {
|
|
|
|
|
cache->flag |= PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= framenr;
|
|
|
|
|
|
|
|
|
|
/* don't write cache on first frame, but on second frame write
|
|
|
|
|
* cache for frame 1 and 2 */
|
|
|
|
|
}
|
|
|
|
|
else if(framedelta == 1) {
|
|
|
|
|
/* if on second frame, write cache for first frame */
|
|
|
|
|
if(framenr == startframe+1)
|
|
|
|
|
cloth_write_cache(ob, clmd, startframe);
|
|
|
|
|
|
|
|
|
|
/* do simulation */
|
|
|
|
|
cache->flag |= PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= framenr;
|
|
|
|
|
|
|
|
|
|
if(!do_step_cloth(ob, clmd, result, framenr)) {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2007-12-12 17:33:59 +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
|
|
|
cloth_write_cache(ob, clmd, framenr);
|
|
|
|
|
|
|
|
|
|
cloth_to_object (ob, clmd, result);
|
2007-11-06 12:08:39 +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
|
|
|
else {
|
|
|
|
|
cache->flag &= ~PTCACHE_SIMULATION_VALID;
|
|
|
|
|
cache->simframe= 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
return result;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* frees all */
|
2008-01-22 23:17:10 +00:00
|
|
|
void cloth_free_modifier ( Object *ob, ClothModifierData *clmd )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
|
|
|
|
Cloth *cloth = NULL;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
|
|
|
|
if ( !clmd )
|
2007-09-16 16:23:21 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
cloth = clmd->clothObject;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
|
|
|
|
|
if ( cloth )
|
|
|
|
|
{
|
|
|
|
|
// If our solver provides a free function, call it
|
|
|
|
|
if ( solvers [clmd->sim_parms->solver_type].free )
|
2007-10-25 22:09:06 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
solvers [clmd->sim_parms->solver_type].free ( clmd );
|
|
|
|
|
}
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
// Free the verts.
|
|
|
|
|
if ( cloth->verts != NULL )
|
|
|
|
|
MEM_freeN ( cloth->verts );
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
cloth->verts = NULL;
|
|
|
|
|
cloth->numverts = 0;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
// Free the springs.
|
|
|
|
|
if ( cloth->springs != NULL )
|
|
|
|
|
{
|
|
|
|
|
LinkNode *search = cloth->springs;
|
|
|
|
|
while(search)
|
2008-01-07 03:20:43 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
ClothSpring *spring = search->link;
|
|
|
|
|
|
|
|
|
|
MEM_freeN ( spring );
|
|
|
|
|
search = search->next;
|
2008-01-07 03:20:43 +00:00
|
|
|
}
|
2008-01-29 02:24:37 +00:00
|
|
|
BLI_linklist_free(cloth->springs, NULL);
|
|
|
|
|
|
2007-10-25 22:09:06 +00:00
|
|
|
cloth->springs = NULL;
|
2008-01-29 02:24:37 +00:00
|
|
|
}
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
cloth->springs = NULL;
|
|
|
|
|
cloth->numsprings = 0;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
// free BVH collision tree
|
2008-05-07 20:42:16 +00:00
|
|
|
if ( cloth->bvhtree )
|
|
|
|
|
BLI_bvhtree_free ( cloth->bvhtree );
|
2008-01-29 02:24:37 +00:00
|
|
|
|
|
|
|
|
// we save our faces for collision objects
|
|
|
|
|
if ( cloth->mfaces )
|
|
|
|
|
MEM_freeN ( cloth->mfaces );
|
2008-02-12 11:04:58 +00:00
|
|
|
|
|
|
|
|
if(cloth->edgehash)
|
|
|
|
|
BLI_edgehash_free ( cloth->edgehash, NULL );
|
|
|
|
|
|
|
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
/*
|
|
|
|
|
if(clmd->clothObject->facemarks)
|
2008-01-29 21:01:12 +00:00
|
|
|
MEM_freeN(clmd->clothObject->facemarks);
|
2008-01-29 02:24:37 +00:00
|
|
|
*/
|
|
|
|
|
MEM_freeN ( cloth );
|
|
|
|
|
clmd->clothObject = NULL;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-22 23:17:10 +00:00
|
|
|
/* frees all */
|
|
|
|
|
void cloth_free_modifier_extern ( ClothModifierData *clmd )
|
|
|
|
|
{
|
|
|
|
|
Cloth *cloth = NULL;
|
2008-01-29 16:32:42 +00:00
|
|
|
if(G.rt > 0)
|
2008-01-29 21:01:12 +00:00
|
|
|
printf("cloth_free_modifier_extern\n");
|
2008-01-29 02:24:37 +00:00
|
|
|
|
2008-01-22 23:17:10 +00:00
|
|
|
if ( !clmd )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
cloth = clmd->clothObject;
|
2008-01-24 10:43:12 +00:00
|
|
|
|
|
|
|
|
if ( cloth )
|
|
|
|
|
{
|
2008-01-29 16:32:42 +00:00
|
|
|
if(G.rt > 0)
|
2008-01-29 21:01:12 +00:00
|
|
|
printf("cloth_free_modifier_extern in\n");
|
2008-01-29 02:24:37 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// If our solver provides a free function, call it
|
2008-01-25 08:55:27 +00:00
|
|
|
if ( solvers [clmd->sim_parms->solver_type].free )
|
2008-01-24 10:43:12 +00:00
|
|
|
{
|
2008-01-25 08:55:27 +00:00
|
|
|
solvers [clmd->sim_parms->solver_type].free ( clmd );
|
2008-01-24 10:43:12 +00:00
|
|
|
}
|
2008-01-22 23:17:10 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// Free the verts.
|
|
|
|
|
if ( cloth->verts != NULL )
|
|
|
|
|
MEM_freeN ( cloth->verts );
|
2008-01-22 23:17:10 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
cloth->verts = NULL;
|
|
|
|
|
cloth->numverts = 0;
|
2008-01-22 23:17:10 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// Free the springs.
|
|
|
|
|
if ( cloth->springs != NULL )
|
|
|
|
|
{
|
|
|
|
|
LinkNode *search = cloth->springs;
|
|
|
|
|
while(search)
|
2008-01-22 23:17:10 +00:00
|
|
|
{
|
2008-01-24 10:43:12 +00:00
|
|
|
ClothSpring *spring = search->link;
|
|
|
|
|
|
|
|
|
|
MEM_freeN ( spring );
|
|
|
|
|
search = search->next;
|
2008-01-22 23:17:10 +00:00
|
|
|
}
|
2008-01-24 10:43:12 +00:00
|
|
|
BLI_linklist_free(cloth->springs, NULL);
|
|
|
|
|
|
2008-01-22 23:17:10 +00:00
|
|
|
cloth->springs = NULL;
|
2008-01-24 10:43:12 +00:00
|
|
|
}
|
2008-01-22 23:17:10 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
cloth->springs = NULL;
|
|
|
|
|
cloth->numsprings = 0;
|
2008-01-22 23:17:10 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// free BVH collision tree
|
2008-05-07 20:42:16 +00:00
|
|
|
if ( cloth->bvhtree )
|
|
|
|
|
BLI_bvhtree_free ( cloth->bvhtree );
|
2008-01-24 10:43:12 +00:00
|
|
|
|
|
|
|
|
// we save our faces for collision objects
|
|
|
|
|
if ( cloth->mfaces )
|
|
|
|
|
MEM_freeN ( cloth->mfaces );
|
2008-02-12 11:04:58 +00:00
|
|
|
|
|
|
|
|
if(cloth->edgehash)
|
|
|
|
|
BLI_edgehash_free ( cloth->edgehash, NULL );
|
|
|
|
|
|
|
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
/*
|
|
|
|
|
if(clmd->clothObject->facemarks)
|
|
|
|
|
MEM_freeN(clmd->clothObject->facemarks);
|
|
|
|
|
*/
|
|
|
|
|
MEM_freeN ( cloth );
|
|
|
|
|
clmd->clothObject = NULL;
|
2008-01-22 23:17:10 +00:00
|
|
|
}
|
|
|
|
|
}
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Internal functions.
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
2008-01-29 21:01:12 +00:00
|
|
|
* cloth_to_object - copies the deformed vertices to the object.
|
|
|
|
|
*
|
|
|
|
|
**/
|
2008-01-24 10:43:12 +00:00
|
|
|
static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *dm)
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
|
|
|
|
unsigned int i = 0;
|
2008-01-24 10:43:12 +00:00
|
|
|
MVert *mvert = NULL;
|
|
|
|
|
unsigned int numverts;
|
|
|
|
|
Cloth *cloth = clmd->clothObject;
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
if (clmd->clothObject) {
|
2008-01-07 03:20:43 +00:00
|
|
|
/* inverse matrix is not uptodate... */
|
2008-01-24 10:43:12 +00:00
|
|
|
Mat4Invert (ob->imat, ob->obmat);
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
mvert = CDDM_get_verts(dm);
|
|
|
|
|
numverts = dm->getNumVerts(dm);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numverts; i++)
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-24 10:43:12 +00:00
|
|
|
VECCOPY (mvert[i].co, cloth->verts[i].x);
|
|
|
|
|
Mat4MulVecfl (ob->imat, mvert[i].co); /* cloth is in global coords */
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-01-29 21:01:12 +00:00
|
|
|
* cloth_apply_vgroup - applies a vertex group as specified by type
|
|
|
|
|
*
|
|
|
|
|
**/
|
2008-01-25 16:14:54 +00:00
|
|
|
/* can be optimized to do all groups in one loop */
|
2008-01-29 02:24:37 +00:00
|
|
|
static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2007-10-25 23:10:42 +00:00
|
|
|
unsigned int i = 0;
|
|
|
|
|
unsigned int j = 0;
|
2008-01-07 03:20:43 +00:00
|
|
|
MDeformVert *dvert = NULL;
|
2007-10-25 23:10:42 +00:00
|
|
|
Cloth *clothObj = NULL;
|
2008-01-07 03:20:43 +00:00
|
|
|
unsigned int numverts = dm->getNumVerts ( dm );
|
2007-10-25 23:10:42 +00:00
|
|
|
float goalfac = 0;
|
|
|
|
|
ClothVertex *verts = NULL;
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
clothObj = clmd->clothObject;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2007-10-25 23:10:42 +00:00
|
|
|
if ( !dm )
|
|
|
|
|
return;
|
2008-01-29 02:24:37 +00:00
|
|
|
|
2008-01-07 03:20:43 +00:00
|
|
|
numverts = dm->getNumVerts ( dm );
|
2007-10-25 23:10:42 +00:00
|
|
|
|
|
|
|
|
verts = clothObj->verts;
|
2008-01-29 02:24:37 +00:00
|
|
|
|
|
|
|
|
if (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) ||
|
|
|
|
|
(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) &&
|
|
|
|
|
((clmd->sim_parms->vgroup_mass>0) ||
|
|
|
|
|
(clmd->sim_parms->vgroup_struct>0)||
|
|
|
|
|
(clmd->sim_parms->vgroup_bend>0)))
|
2007-10-25 23:10:42 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
for ( i = 0; i < numverts; i++, verts++ )
|
2008-03-06 01:21:40 +00:00
|
|
|
{
|
2007-10-25 23:10:42 +00:00
|
|
|
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
|
|
|
|
|
if ( dvert )
|
|
|
|
|
{
|
|
|
|
|
for ( j = 0; j < dvert->totweight; j++ )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ))
|
|
|
|
|
{
|
|
|
|
|
verts->goal = dvert->dw [j].weight;
|
|
|
|
|
goalfac= 1.0f;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// Kicking goal factor to simplify things...who uses that anyway?
|
|
|
|
|
// ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal );
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
verts->goal = ( float ) pow ( verts->goal , 4.0f );
|
|
|
|
|
if ( verts->goal >=SOFTGOALSNAP )
|
2008-02-06 22:59:56 +00:00
|
|
|
{
|
|
|
|
|
verts->flags |= CLOTH_VERT_FLAG_PINNED;
|
|
|
|
|
}
|
2008-01-29 02:24:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_struct-1))
|
2008-01-25 16:14:54 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
verts->struct_stiff = dvert->dw [j].weight;
|
|
|
|
|
verts->shear_stiff = dvert->dw [j].weight;
|
2008-01-25 16:14:54 +00:00
|
|
|
}
|
2008-01-21 02:23:03 +00:00
|
|
|
|
2008-01-29 02:24:37 +00:00
|
|
|
if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_bend-1))
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-29 02:24:37 +00:00
|
|
|
verts->bend_stiff = dvert->dw [j].weight;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-02-06 22:59:56 +00:00
|
|
|
/*
|
|
|
|
|
// for later
|
|
|
|
|
if( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_weight-1))
|
2008-02-03 22:37:43 +00:00
|
|
|
{
|
|
|
|
|
verts->mass = dvert->dw [j].weight;
|
|
|
|
|
}
|
2008-02-06 22:59:56 +00:00
|
|
|
*/
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-01-07 03:20:43 +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 int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first)
|
2008-01-07 03:20:43 +00:00
|
|
|
{
|
|
|
|
|
unsigned int i = 0;
|
2008-01-24 10:43:12 +00:00
|
|
|
MVert *mvert = NULL;
|
2008-01-07 03:20:43 +00:00
|
|
|
ClothVertex *verts = NULL;
|
|
|
|
|
float tnull[3] = {0,0,0};
|
2008-02-08 00:55:48 +00:00
|
|
|
Cloth *cloth = NULL;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// If we have a clothObject, free it.
|
2008-01-07 03:20:43 +00:00
|
|
|
if ( clmd->clothObject != NULL )
|
2008-01-25 08:55:27 +00:00
|
|
|
{
|
2008-01-22 23:17:10 +00:00
|
|
|
cloth_free_modifier ( ob, clmd );
|
2008-01-29 16:32:42 +00:00
|
|
|
if(G.rt > 0)
|
2008-01-29 21:01:12 +00:00
|
|
|
printf("cloth_free_modifier cloth_from_object\n");
|
2008-01-25 08:55:27 +00:00
|
|
|
}
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// Allocate a new cloth object.
|
2008-01-07 03:20:43 +00:00
|
|
|
clmd->clothObject = MEM_callocN ( sizeof ( Cloth ), "cloth" );
|
|
|
|
|
if ( clmd->clothObject )
|
|
|
|
|
{
|
|
|
|
|
clmd->clothObject->old_solver_type = 255;
|
|
|
|
|
// clmd->clothObject->old_collision_type = 255;
|
2008-02-08 00:55:48 +00:00
|
|
|
cloth = clmd->clothObject;
|
2008-02-12 11:04:58 +00:00
|
|
|
clmd->clothObject->edgehash = NULL;
|
2008-01-07 03:20:43 +00:00
|
|
|
}
|
|
|
|
|
else if ( !clmd->clothObject )
|
|
|
|
|
{
|
|
|
|
|
modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject." );
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-12-21 01:24:09 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
// mesh input objects need DerivedMesh
|
|
|
|
|
if ( !dm )
|
|
|
|
|
return 0;
|
2007-10-25 23:10:42 +00:00
|
|
|
|
2008-01-24 10:43:12 +00:00
|
|
|
cloth_from_mesh ( ob, clmd, dm );
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
// create springs
|
|
|
|
|
clmd->clothObject->springs = NULL;
|
|
|
|
|
clmd->clothObject->numsprings = -1;
|
|
|
|
|
|
|
|
|
|
mvert = dm->getVertArray ( dm );
|
|
|
|
|
verts = clmd->clothObject->verts;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
// set initial values
|
|
|
|
|
for ( i = 0; i < dm->getNumVerts(dm); i++, verts++ )
|
|
|
|
|
{
|
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(first)
|
2008-01-24 10:43:12 +00:00
|
|
|
{
|
|
|
|
|
VECCOPY ( verts->x, mvert[i].co );
|
|
|
|
|
Mat4MulVecfl ( ob->obmat, verts->x );
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-11 13:30:52 +00:00
|
|
|
/* no GUI interface yet */
|
2008-03-06 01:21:40 +00:00
|
|
|
verts->mass = clmd->sim_parms->mass;
|
|
|
|
|
verts->impulse_count = 0;
|
2008-01-07 03:20:43 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
|
|
|
|
|
verts->goal= clmd->sim_parms->defgoal;
|
|
|
|
|
else
|
|
|
|
|
verts->goal= 0.0f;
|
|
|
|
|
|
|
|
|
|
verts->flags = 0;
|
|
|
|
|
VECCOPY ( verts->xold, verts->x );
|
|
|
|
|
VECCOPY ( verts->xconst, verts->x );
|
|
|
|
|
VECCOPY ( verts->txold, verts->x );
|
2008-05-07 20:42:16 +00:00
|
|
|
VECCOPY ( verts->tx, verts->x );
|
2008-01-29 16:32:42 +00:00
|
|
|
VecMulf ( verts->v, 0.0f );
|
|
|
|
|
|
|
|
|
|
verts->impulse_count = 0;
|
|
|
|
|
VECCOPY ( verts->impulse, tnull );
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2008-01-29 16:32:42 +00:00
|
|
|
|
|
|
|
|
// apply / set vertex groups
|
|
|
|
|
// has to be happen before springs are build!
|
|
|
|
|
cloth_apply_vgroup (clmd, dm);
|
|
|
|
|
|
2008-02-03 22:37:43 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
if ( !cloth_build_springs ( clmd, dm ) )
|
|
|
|
|
{
|
|
|
|
|
cloth_free_modifier ( ob, clmd );
|
|
|
|
|
modifier_setError ( & ( clmd->modifier ), "Can't build springs." );
|
|
|
|
|
printf("cloth_free_modifier cloth_build_springs\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-08 00:55:48 +00:00
|
|
|
for ( i = 0; i < dm->getNumVerts(dm); i++)
|
|
|
|
|
{
|
|
|
|
|
if((!(cloth->verts[i].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[i].goal > ALMOST_ZERO))
|
|
|
|
|
{
|
|
|
|
|
cloth_add_spring (clmd, i, i, 0.0, CLOTH_SPRING_TYPE_GOAL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-03 22:37:43 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
// init our solver
|
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 ( solvers [clmd->sim_parms->solver_type].init ) {
|
2008-01-29 16:32:42 +00:00
|
|
|
solvers [clmd->sim_parms->solver_type].init ( ob, clmd );
|
Point Cache Refactoring
=======================
Caching and Baking:
- The point cache is now cleared on DAG_object_flush_update(), and not cleared for time dependency graph updates.
- There is now a Bake button instead of Protect. Also cache start and end frames were added to softbody and particles.
- The cloth autoprotect feature was removed.
- The Ctrl+B menu now also bakes cloth and particles next to softbody and fluids. Additionally there are now frree bake and free cache menu entries.
- The point cache api has been changed. There is now a PTCacheID struct for each point cache type that can be filled and then used to call the point cache functions.
- PointCache struct was added to DNA and is automatically allocated for each physics type.
- Soft body now supports Bake Editing just like cloth.
- Tried to make the systems deal consistently with time ipo's and offsets. Still not sure it all works correct, but too complicated to solve completely now.
Library Linking:
- Added some more warnings to prevent editing settings on library linked objects.
- Linked objects now read from the cache located next to the original library file, and never write to it. This restores old behavior for softbodies. For local simulation the mesh and not the object should be linked.
- Dupligroups and proxies can't create local point caches at the moment, how to implement that I'm not sure. We probably need a proxy point cache for that to work (ugh).
Physics UI:
- Renamed deflection panel to collision for consistency and reorganized the buttons. Also removed some softbody collision buttons from the softbody panel that were duplicated in this panel for cloth.
- Tweaked field panel buttons to not jump around when changing options.
- Tabbing e.g. Soft Body Collision into the Soft Body panel, it now only shows Collision to make the panel names readable.
- I tried to make enabled/disabling physics more consistent, since all three system did things different. Now the two modifier buttons to enable the modifier for the viewport and rendering are also duplicated in the physics panels. Toggling the Soft Body and Cloth buttons now both remove their modifiers.
- Fixed modifier error drawing glitch.
Particles:
- Particles are now recalculated more often than before. Previously it did partial updates based on the changes, but that doesn't work well with DAG_object_flush_update() ..
- Fixed memory leak loading keyed particle system. Now keys are not written to file anymore but always created after loading.
- Make particle threads work with autothreads.
Continue Physics:
- The timeline play now has a Continue Physics option in the playback menu, which keeps the simulations going without writing them to the cache.
- This doesn't always work that well, some changes are not immediately updated, but this can be improved later. Still it's fun to get a feel for the physics.
Todo:
- Point cache can get out of sync with and undo and changing a file without saving it.
- Change the point cache file format to store a version (so old point cache files can be either converted or at least ignored), and to do correct endian conversion.
- Menu item and/or buttons for Ctrl+B.
- A system("rm ..") was changed to remove() since the former is very slow for clearing point caches. These system() calls were already giving trouble in a bug in the tracker, but really most use of this system("") should be changed and tested.
- The Soft Body Collision and Clot Collision panel titles don't mention there's point cache settings there too, doing that makes them unreadable with the default panel setup.. but may need to make the names longer anyway.
2008-04-10 11:39:20 +00:00
|
|
|
}
|
2008-02-13 10:44:36 +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(!first)
|
2008-02-13 10:44:36 +00:00
|
|
|
implicit_set_positions(clmd);
|
2008-01-29 16:32:42 +00:00
|
|
|
|
2008-05-14 16:09:56 +00:00
|
|
|
BENCH(clmd->clothObject->bvhtree = bvhtree_build_from_cloth ( clmd, clmd->coll_parms->epsilon ));
|
2008-05-07 20:42:16 +00:00
|
|
|
|
2008-01-29 16:32:42 +00:00
|
|
|
return 1;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-07 03:20:43 +00:00
|
|
|
static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-07 03:20:43 +00:00
|
|
|
unsigned int numverts = dm->getNumVerts ( dm );
|
|
|
|
|
unsigned int numfaces = dm->getNumFaces ( dm );
|
2008-01-24 10:43:12 +00:00
|
|
|
MFace *mface = CDDM_get_faces(dm);
|
2008-01-07 03:20:43 +00:00
|
|
|
unsigned int i = 0;
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2008-02-12 11:04:58 +00:00
|
|
|
/* Allocate our vertices. */
|
2007-09-16 16:23:21 +00:00
|
|
|
clmd->clothObject->numverts = numverts;
|
2008-01-07 03:20:43 +00:00
|
|
|
clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" );
|
|
|
|
|
if ( clmd->clothObject->verts == NULL )
|
2007-10-25 23:10:42 +00:00
|
|
|
{
|
2008-01-22 23:17:10 +00:00
|
|
|
cloth_free_modifier ( ob, clmd );
|
2008-01-07 03:20:43 +00:00
|
|
|
modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject->verts." );
|
2008-01-29 02:24:37 +00:00
|
|
|
printf("cloth_free_modifier clmd->clothObject->verts\n");
|
2007-11-06 12:08:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2007-10-25 23:10:42 +00:00
|
|
|
|
|
|
|
|
// save face information
|
2007-10-25 22:09:06 +00:00
|
|
|
clmd->clothObject->numfaces = numfaces;
|
2008-01-07 03:20:43 +00:00
|
|
|
clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" );
|
|
|
|
|
if ( clmd->clothObject->mfaces == NULL )
|
2007-10-22 22:50:32 +00:00
|
|
|
{
|
2008-01-22 23:17:10 +00:00
|
|
|
cloth_free_modifier ( ob, clmd );
|
2008-01-07 03:20:43 +00:00
|
|
|
modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject->mfaces." );
|
2008-01-29 02:24:37 +00:00
|
|
|
printf("cloth_free_modifier clmd->clothObject->mfaces\n");
|
2007-10-25 22:09:06 +00:00
|
|
|
return;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2008-01-07 03:20:43 +00:00
|
|
|
for ( i = 0; i < numfaces; i++ )
|
|
|
|
|
memcpy ( &clmd->clothObject->mfaces[i], &mface[i], sizeof ( MFace ) );
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
/* Free the springs since they can't be correct if the vertices
|
|
|
|
|
* changed.
|
|
|
|
|
*/
|
2008-01-07 03:20:43 +00:00
|
|
|
if ( clmd->clothObject->springs != NULL )
|
|
|
|
|
MEM_freeN ( clmd->clothObject->springs );
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***************************************************************************************
|
|
|
|
|
* SPRING NETWORK BUILDING IMPLEMENTATION BEGIN
|
|
|
|
|
***************************************************************************************/
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
// be carefull: implicit solver has to be resettet when using this one!
|
2008-01-21 10:55:46 +00:00
|
|
|
// --> only for implicit handling of this spring!
|
2007-10-18 23:12:30 +00:00
|
|
|
int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type)
|
|
|
|
|
{
|
|
|
|
|
Cloth *cloth = clmd->clothObject;
|
|
|
|
|
ClothSpring *spring = NULL;
|
|
|
|
|
|
|
|
|
|
if(cloth)
|
|
|
|
|
{
|
|
|
|
|
// TODO: look if this spring is already there
|
|
|
|
|
|
|
|
|
|
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
|
|
|
|
|
2008-02-26 14:25:29 +00:00
|
|
|
if(!spring)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
spring->ij = indexA;
|
|
|
|
|
spring->kl = indexB;
|
|
|
|
|
spring->restlen = restlength;
|
|
|
|
|
spring->type = spring_type;
|
|
|
|
|
spring->flags = 0;
|
2008-02-08 00:55:48 +00:00
|
|
|
spring->stiffness = 0;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
|
|
|
|
cloth->numsprings++;
|
|
|
|
|
|
2008-02-08 00:55:48 +00:00
|
|
|
BLI_linklist_prepend ( &cloth->springs, spring );
|
2007-10-22 22:50:32 +00:00
|
|
|
|
|
|
|
|
return 1;
|
2007-10-18 23:12:30 +00:00
|
|
|
}
|
2007-10-22 22:50:32 +00:00
|
|
|
return 0;
|
2007-10-18 23:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2008-02-26 14:25:29 +00:00
|
|
|
void cloth_free_errorsprings(Cloth *cloth, EdgeHash *edgehash, LinkNode **edgelist)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
|
|
if ( cloth->springs != NULL )
|
|
|
|
|
{
|
|
|
|
|
LinkNode *search = cloth->springs;
|
|
|
|
|
while(search)
|
|
|
|
|
{
|
|
|
|
|
ClothSpring *spring = search->link;
|
|
|
|
|
|
|
|
|
|
MEM_freeN ( spring );
|
|
|
|
|
search = search->next;
|
|
|
|
|
}
|
|
|
|
|
BLI_linklist_free(cloth->springs, NULL);
|
|
|
|
|
|
|
|
|
|
cloth->springs = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(edgelist)
|
|
|
|
|
{
|
|
|
|
|
for ( i = 0; i < cloth->numverts; i++ )
|
|
|
|
|
{
|
|
|
|
|
BLI_linklist_free ( edgelist[i],NULL );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_freeN ( edgelist );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cloth->edgehash)
|
|
|
|
|
BLI_edgehash_free ( cloth->edgehash, NULL );
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-23 13:24:44 +00:00
|
|
|
int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-01-23 13:24:44 +00:00
|
|
|
Cloth *cloth = clmd->clothObject;
|
2007-10-18 23:12:30 +00:00
|
|
|
ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL;
|
2007-09-16 16:23:21 +00:00
|
|
|
unsigned int struct_springs = 0, shear_springs=0, bend_springs = 0;
|
2008-01-22 23:17:10 +00:00
|
|
|
unsigned int i = 0;
|
2007-10-18 23:12:30 +00:00
|
|
|
unsigned int numverts = dm->getNumVerts ( dm );
|
|
|
|
|
unsigned int numedges = dm->getNumEdges ( dm );
|
|
|
|
|
unsigned int numfaces = dm->getNumFaces ( dm );
|
|
|
|
|
MEdge *medge = CDDM_get_edges ( dm );
|
|
|
|
|
MFace *mface = CDDM_get_faces ( dm );
|
2007-09-16 16:23:21 +00:00
|
|
|
unsigned int index2 = 0; // our second vertex index
|
|
|
|
|
LinkNode **edgelist = NULL;
|
|
|
|
|
EdgeHash *edgehash = NULL;
|
2007-10-18 23:12:30 +00:00
|
|
|
LinkNode *search = NULL, *search2 = NULL;
|
2008-01-22 23:17:10 +00:00
|
|
|
float temp[3];
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
// error handling
|
2007-10-18 23:12:30 +00:00
|
|
|
if ( numedges==0 )
|
2007-09-16 16:23:21 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
cloth->springs = NULL;
|
|
|
|
|
|
|
|
|
|
edgelist = MEM_callocN ( sizeof ( LinkNode * ) * numverts, "cloth_edgelist_alloc" );
|
2008-02-26 14:25:29 +00:00
|
|
|
|
|
|
|
|
if(!edgelist)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
for ( i = 0; i < numverts; i++ )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
|
|
|
|
edgelist[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
if ( cloth->springs )
|
|
|
|
|
MEM_freeN ( cloth->springs );
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
// create spring network hash
|
|
|
|
|
edgehash = BLI_edgehash_new();
|
|
|
|
|
|
|
|
|
|
// structural springs
|
2007-10-18 23:12:30 +00:00
|
|
|
for ( i = 0; i < numedges; i++ )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2007-10-18 23:12:30 +00:00
|
|
|
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
|
|
|
|
|
|
|
|
|
if ( spring )
|
|
|
|
|
{
|
2008-02-26 09:55:07 +00:00
|
|
|
spring->ij = MIN2(medge[i].v1, medge[i].v2);
|
|
|
|
|
spring->kl = MAX2(medge[i].v2, medge[i].v1);
|
2008-01-21 10:55:46 +00:00
|
|
|
VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x );
|
2007-10-18 23:12:30 +00:00
|
|
|
spring->restlen = sqrt ( INPR ( temp, temp ) );
|
2008-02-12 11:04:58 +00:00
|
|
|
clmd->sim_parms->avg_spring_len += spring->restlen;
|
|
|
|
|
cloth->verts[spring->ij].avg_spring_len += spring->restlen;
|
|
|
|
|
cloth->verts[spring->kl].avg_spring_len += spring->restlen;
|
|
|
|
|
cloth->verts[spring->ij].spring_count++;
|
|
|
|
|
cloth->verts[spring->kl].spring_count++;
|
2007-10-18 23:12:30 +00:00
|
|
|
spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
|
|
|
|
|
spring->flags = 0;
|
2008-01-25 16:14:54 +00:00
|
|
|
spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0;
|
2007-10-18 23:12:30 +00:00
|
|
|
struct_springs++;
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2008-02-20 15:54:34 +00:00
|
|
|
BLI_linklist_prepend ( &cloth->springs, spring );
|
2008-01-29 21:01:12 +00:00
|
|
|
}
|
2008-02-26 14:25:29 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
|
|
|
|
return 0;
|
2007-11-26 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2008-02-26 14:25:29 +00:00
|
|
|
if(struct_springs > 0)
|
|
|
|
|
clmd->sim_parms->avg_spring_len /= struct_springs;
|
2008-02-12 11:04:58 +00:00
|
|
|
|
|
|
|
|
for(i = 0; i < numverts; i++)
|
|
|
|
|
{
|
|
|
|
|
cloth->verts[i].avg_spring_len = cloth->verts[i].avg_spring_len * 0.49 / ((float)cloth->verts[i].spring_count);
|
|
|
|
|
}
|
2008-01-23 13:24:44 +00:00
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
// shear springs
|
2007-10-18 23:12:30 +00:00
|
|
|
for ( i = 0; i < numfaces; i++ )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-03-02 22:01:43 +00:00
|
|
|
// triangle faces already have shear springs due to structural geometry
|
2008-03-02 23:20:20 +00:00
|
|
|
if ( !mface[i].v4 )
|
2008-03-02 22:01:43 +00:00
|
|
|
continue;
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
spring = ( ClothSpring *) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
2008-02-26 14:25:29 +00:00
|
|
|
|
|
|
|
|
if(!spring)
|
|
|
|
|
{
|
|
|
|
|
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2008-02-26 09:55:07 +00:00
|
|
|
spring->ij = MIN2(mface[i].v1, mface[i].v3);
|
|
|
|
|
spring->kl = MAX2(mface[i].v3, mface[i].v1);
|
2008-01-21 10:55:46 +00:00
|
|
|
VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x );
|
2007-10-18 23:12:30 +00:00
|
|
|
spring->restlen = sqrt ( INPR ( temp, temp ) );
|
|
|
|
|
spring->type = CLOTH_SPRING_TYPE_SHEAR;
|
2008-01-25 16:14:54 +00:00
|
|
|
spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0;
|
2007-09-16 16:23:21 +00:00
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
BLI_linklist_append ( &edgelist[spring->ij], spring );
|
|
|
|
|
BLI_linklist_append ( &edgelist[spring->kl], spring );
|
2007-09-16 16:23:21 +00:00
|
|
|
shear_springs++;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-02-20 15:54:34 +00:00
|
|
|
BLI_linklist_prepend ( &cloth->springs, spring );
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-03-02 22:01:43 +00:00
|
|
|
|
|
|
|
|
// if ( mface[i].v4 ) --> Quad face
|
|
|
|
|
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
|
|
|
|
|
|
|
|
|
if(!spring)
|
2007-09-21 13:34:19 +00:00
|
|
|
{
|
2008-03-02 22:01:43 +00:00
|
|
|
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-03-02 22:01:43 +00:00
|
|
|
spring->ij = MIN2(mface[i].v2, mface[i].v4);
|
|
|
|
|
spring->kl = MAX2(mface[i].v4, mface[i].v2);
|
|
|
|
|
VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x );
|
|
|
|
|
spring->restlen = sqrt ( INPR ( temp, temp ) );
|
|
|
|
|
spring->type = CLOTH_SPRING_TYPE_SHEAR;
|
|
|
|
|
spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-03-02 22:01:43 +00:00
|
|
|
BLI_linklist_append ( &edgelist[spring->ij], spring );
|
|
|
|
|
BLI_linklist_append ( &edgelist[spring->kl], spring );
|
|
|
|
|
shear_springs++;
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-03-02 22:01:43 +00:00
|
|
|
BLI_linklist_prepend ( &cloth->springs, spring );
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2007-09-16 16:23:21 +00:00
|
|
|
// bending springs
|
2007-10-18 23:12:30 +00:00
|
|
|
search2 = cloth->springs;
|
|
|
|
|
for ( i = struct_springs; i < struct_springs+shear_springs; i++ )
|
|
|
|
|
{
|
|
|
|
|
if ( !search2 )
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
tspring2 = search2->link;
|
|
|
|
|
search = edgelist[tspring2->kl];
|
|
|
|
|
while ( search )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
|
|
|
|
tspring = search->link;
|
2007-10-18 23:12:30 +00:00
|
|
|
index2 = ( ( tspring->ij==tspring2->kl ) ? ( tspring->kl ) : ( tspring->ij ) );
|
|
|
|
|
|
|
|
|
|
// check for existing spring
|
|
|
|
|
// check also if startpoint is equal to endpoint
|
2008-02-28 23:12:50 +00:00
|
|
|
if ( !BLI_edgehash_haskey ( edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2) )
|
|
|
|
|
&& ( index2!=tspring2->ij ) )
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2007-10-18 23:12:30 +00:00
|
|
|
spring = ( ClothSpring * ) MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
2008-02-26 14:25:29 +00:00
|
|
|
|
|
|
|
|
if(!spring)
|
|
|
|
|
{
|
|
|
|
|
cloth_free_errorsprings(cloth, edgehash, edgelist);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-10-18 23:12:30 +00:00
|
|
|
|
2008-02-26 09:55:07 +00:00
|
|
|
spring->ij = MIN2(tspring2->ij, index2);
|
|
|
|
|
spring->kl = MAX2(tspring2->ij, index2);
|
2008-02-28 23:12:50 +00:00
|
|
|
VECSUB ( temp, cloth->verts[spring->kl].x, cloth->verts[spring->ij].x );
|
2007-10-18 23:12:30 +00:00
|
|
|
spring->restlen = sqrt ( INPR ( temp, temp ) );
|
|
|
|
|
spring->type = CLOTH_SPRING_TYPE_BENDING;
|
2008-01-25 16:14:54 +00:00
|
|
|
spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0;
|
2008-02-28 23:12:50 +00:00
|
|
|
BLI_edgehash_insert ( edgehash, spring->ij, spring->kl, NULL );
|
2007-09-16 16:23:21 +00:00
|
|
|
bend_springs++;
|
|
|
|
|
|
2008-02-20 15:54:34 +00:00
|
|
|
BLI_linklist_prepend ( &cloth->springs, spring );
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2007-10-18 23:12:30 +00:00
|
|
|
search = search->next;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2007-10-18 23:12:30 +00:00
|
|
|
search2 = search2->next;
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2008-02-28 23:12:50 +00:00
|
|
|
/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
|
|
|
|
|
for ( i = 0; i < numedges; i++ ) // struct springs
|
|
|
|
|
BLI_edgehash_insert ( edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL );
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2008-02-28 23:12:50 +00:00
|
|
|
for ( i = 0; i < numfaces; i++ ) // edge springs
|
2007-09-16 16:23:21 +00:00
|
|
|
{
|
2008-02-28 23:12:50 +00:00
|
|
|
if(mface[i].v4)
|
|
|
|
|
{
|
2008-03-02 23:20:20 +00:00
|
|
|
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL );
|
|
|
|
|
|
2008-02-28 23:12:50 +00:00
|
|
|
BLI_edgehash_insert ( edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL );
|
|
|
|
|
}
|
2007-09-16 16:23:21 +00:00
|
|
|
}
|
2008-02-28 23:12:50 +00:00
|
|
|
|
|
|
|
|
|
2008-01-29 21:01:12 +00:00
|
|
|
cloth->numsprings = struct_springs + shear_springs + bend_springs;
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
if ( edgelist )
|
2008-02-26 14:25:29 +00:00
|
|
|
{
|
|
|
|
|
for ( i = 0; i < numverts; i++ )
|
|
|
|
|
{
|
|
|
|
|
BLI_linklist_free ( edgelist[i],NULL );
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-18 23:12:30 +00:00
|
|
|
MEM_freeN ( edgelist );
|
2008-02-26 14:25:29 +00:00
|
|
|
}
|
2008-01-29 21:01:12 +00:00
|
|
|
|
2008-02-12 11:04:58 +00:00
|
|
|
cloth->edgehash = edgehash;
|
2008-01-21 10:55:46 +00:00
|
|
|
|
2008-02-03 22:37:43 +00:00
|
|
|
if(G.rt>0)
|
2008-02-12 11:04:58 +00:00
|
|
|
printf("avg_len: %f\n",clmd->sim_parms->avg_spring_len);
|
2007-09-16 16:23:21 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
} /* cloth_build_springs */
|
|
|
|
|
/***************************************************************************************
|
|
|
|
|
* SPRING NETWORK BUILDING IMPLEMENTATION END
|
|
|
|
|
***************************************************************************************/
|
|
|
|
|
|