Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 13:25:24 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 13:25:24 +0400
commit527ddb0a5bcb9cd0b132a449b40987f70817bb31 (patch)
tree6e5851c32d5bb95d96108599f20978737ab0f9ad /source/blender/blenkernel/intern/lattice.c
parent0312b183194e703d778e6b989caccdfa35059d13 (diff)
Move bevel list and path from Curve to Object datablock
I know this is not so much nice to have this guys hanging around in a general Object datablock and ideally they better be wrapped around into a structure like DerivedMesh or something like this. But this is pure runtime only stuff and we could re-wrap them around later. Main purpose of this is making curves more thread safe, so no separate threads will ever start freeing the same path or the same bevel list. It also makes sense because path and bevel shall include deformation coming from modifiers which are applying on pre-tesselation point and different objects could have different set of modifiers. This used to be really confusing in the past and now data which depends on object is stored in an object, making things clear for understanding even. This doesn't make curve code fully thread-safe due to pre-tesselation modifiers still modifies actual nurbs and lock is still needed in makeDispListsCurveTypes, but this change makes usage of paths safe for threading. Once modifiers will stop modifying actual nurbs, curves will be fully safe for threading. Actually, this commit also contains wrapping runtime curve members into own structure This allows easier assignment on file loading, keeps curve- specific runtime data grouped and saves couple of bytes in Object for non-curve types. -- svn merge -r57938:57939 ^/branches/soc-2013-depsgraph_mt svn merge -r57957:57958^/branches/soc-2013-depsgraph_mt
Diffstat (limited to 'source/blender/blenkernel/intern/lattice.c')
-rw-r--r--source/blender/blenkernel/intern/lattice.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 069c3ab8ea2..b6baeea51b1 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -51,6 +51,7 @@
#include "BKE_animsys.h"
#include "BKE_anim.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_key.h"
@@ -164,7 +165,7 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
/* prevent using deformed locations */
- BKE_displist_free(&ltOb->disp);
+ BKE_displist_free(&ltOb->curve_cache->disp);
copy_m4_m4(mat, ltOb->obmat);
unit_m4(ltOb->obmat);
@@ -311,7 +312,7 @@ void init_latt_deform(Object *oblatt, Object *ob)
/* we make an array with all differences */
Lattice *lt = oblatt->data;
BPoint *bp;
- DispList *dl = BKE_displist_find(&oblatt->disp, DL_VERTS);
+ DispList *dl = oblatt->curve_cache ? BKE_displist_find(&oblatt->curve_cache->disp, DL_VERTS) : NULL;
float *co = dl ? dl->verts : NULL;
float *fp, imat[4][4];
float fu, fv, fw;
@@ -506,13 +507,12 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd)
*/
static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius)
{
- Curve *cu = ob->data;
BevList *bl;
float ctime1;
int cycl = 0;
/* test for cyclic */
- bl = cu->bev.first;
+ bl = ob->curve_cache->bev.first;
if (!bl->nr) return 0;
if (bl->poly > -1) cycl = 1;
@@ -527,7 +527,7 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir
if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
if (cycl == 0) {
- Path *path = cu->path;
+ Path *path = ob->curve_cache->path;
float dvec[3];
if (ctime < 0.0f) {
@@ -565,9 +565,9 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
const int is_neg_axis = (axis > 2);
/* to be sure, mostly after file load */
- if (cu->path == NULL) {
+ if (ELEM(NULL, par->curve_cache, par->curve_cache->path)) {
BKE_displist_make_curveTypes(scene, par, 0);
- if (cu->path == NULL) return 0; // happens on append...
+ if (par->curve_cache->path == NULL) return 0; // happens on append...
}
/* options */
@@ -576,14 +576,14 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3],
if (cu->flag & CU_STRETCH)
fac = (-co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]);
else
- fac = -(co[index] - cd->dmax[index]) / (cu->path->totdist);
+ fac = -(co[index] - cd->dmax[index]) / (par->curve_cache->path->totdist);
}
else {
index = axis;
if (cu->flag & CU_STRETCH)
fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]);
else
- fac = +(co[index] - cd->dmin[index]) / (cu->path->totdist);
+ fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
}
if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
@@ -996,7 +996,12 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
float (*vertexCos)[3] = NULL;
int numVerts, editmode = (lt->editlatt != NULL);
- BKE_displist_free(&ob->disp);
+ if (ob->curve_cache) {
+ BKE_displist_free(&ob->curve_cache->disp);
+ }
+ else {
+ ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for lattice");
+ }
for (; md; md = md->next) {
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1022,7 +1027,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob)
dl->nr = numVerts;
dl->verts = (float *) vertexCos;
- BLI_addtail(&ob->disp, dl);
+ BLI_addtail(&ob->curve_cache->disp, dl);
}
}