Wrap 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.
This commit is contained in:
@@ -42,6 +42,13 @@ struct Main;
|
||||
struct Nurb;
|
||||
struct Object;
|
||||
struct Scene;
|
||||
struct Path;
|
||||
|
||||
typedef struct CurveCache {
|
||||
ListBase disp;
|
||||
ListBase bev;
|
||||
struct Path *path;
|
||||
} CurveCache;
|
||||
|
||||
#define KNOTSU(nu) ( (nu)->orderu + (nu)->pntsu + (((nu)->flagu & CU_NURB_CYCLIC) ? ((nu)->orderu - 1) : 0) )
|
||||
#define KNOTSV(nu) ( (nu)->orderv + (nu)->pntsv + (((nu)->flagv & CU_NURB_CYCLIC) ? ((nu)->orderv - 1) : 0) )
|
||||
|
||||
@@ -60,6 +60,7 @@ void BKE_object_copy_softbody(struct Object *obn, struct Object *ob);
|
||||
void BKE_object_free_particlesystems(struct Object *ob);
|
||||
void BKE_object_free_softbody(struct Object *ob);
|
||||
void BKE_object_free_bulletsoftbody(struct Object *ob);
|
||||
void BKE_object_free_curve_cache(struct Object *ob);
|
||||
void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob);
|
||||
|
||||
void BKE_object_free(struct Object *ob);
|
||||
|
||||
@@ -509,11 +509,11 @@ void calc_curvepath(Object *ob)
|
||||
}
|
||||
cu = ob->data;
|
||||
|
||||
if (ob->path) free_path(ob->path);
|
||||
ob->path = NULL;
|
||||
if (ob->curve_cache->path) free_path(ob->curve_cache->path);
|
||||
ob->curve_cache->path = NULL;
|
||||
|
||||
/* weak! can only use first curve */
|
||||
bl = ob->bev.first;
|
||||
bl = ob->curve_cache->bev.first;
|
||||
if (bl == NULL || !bl->nr) {
|
||||
return;
|
||||
}
|
||||
@@ -521,7 +521,7 @@ void calc_curvepath(Object *ob)
|
||||
nurbs = BKE_curve_nurbs_get(cu);
|
||||
nu = nurbs->first;
|
||||
|
||||
ob->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
|
||||
ob->curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
|
||||
|
||||
/* if POLY: last vertice != first vertice */
|
||||
cycl = (bl->poly != -1);
|
||||
@@ -630,15 +630,15 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua
|
||||
|
||||
if (ob == NULL || ob->type != OB_CURVE) return 0;
|
||||
cu = ob->data;
|
||||
if (ob->path == NULL || ob->path->data == NULL) {
|
||||
if (ob->curve_cache == NULL || ob->curve_cache->path == NULL || ob->curve_cache->path->data == NULL) {
|
||||
printf("no path!\n");
|
||||
return 0;
|
||||
}
|
||||
path = ob->path;
|
||||
path = ob->curve_cache->path;
|
||||
pp = path->data;
|
||||
|
||||
/* test for cyclic */
|
||||
bl = ob->bev.first;
|
||||
bl = ob->curve_cache->bev.first;
|
||||
if (!bl) return 0;
|
||||
if (!bl->nr) return 0;
|
||||
if (bl->poly > -1) cycl = 1;
|
||||
|
||||
@@ -1821,11 +1821,11 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ELEM(NULL, ikData->tar->path, ikData->tar->path->data)) {
|
||||
if (ELEM3(NULL, ikData->tar->curve_cache, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
|
||||
BKE_displist_make_curveTypes(scene, ikData->tar, 0);
|
||||
|
||||
/* path building may fail in EditMode after removing verts [#33268]*/
|
||||
if (ELEM(NULL, ikData->tar->path, ikData->tar->path->data)) {
|
||||
if (ELEM(NULL, ikData->tar->curve_cache->path, ikData->tar->curve_cache->path->data)) {
|
||||
/* BLI_assert(cu->path != NULL); */
|
||||
return;
|
||||
}
|
||||
@@ -1901,7 +1901,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos
|
||||
|
||||
/* get the current length of the curve */
|
||||
/* NOTE: this is assumed to be correct even after the curve was resized */
|
||||
splineLen = ikData->tar->path->totdist;
|
||||
splineLen = ikData->tar->curve_cache->path->totdist;
|
||||
|
||||
/* calculate the scale factor to multiply all the path values by so that the
|
||||
* bone chain retains its current length, such that
|
||||
|
||||
@@ -1818,7 +1818,13 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
|
||||
|
||||
DerivedMesh *CDDM_from_curve(Object *ob)
|
||||
{
|
||||
return CDDM_from_curve_displist(ob, &ob->disp);
|
||||
ListBase disp = {NULL};
|
||||
|
||||
if (ob->curve_cache) {
|
||||
disp = ob->curve_cache->disp;
|
||||
}
|
||||
|
||||
return CDDM_from_curve_displist(ob, &disp);
|
||||
}
|
||||
|
||||
DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase)
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include "BKE_bvhutils.h"
|
||||
#include "BKE_camera.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_DerivedMesh.h" /* for geometry targets */
|
||||
@@ -449,7 +450,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
|
||||
{
|
||||
Lattice *lt = (Lattice *)ob->data;
|
||||
|
||||
DispList *dl = BKE_displist_find(&ob->disp, DL_VERTS);
|
||||
DispList *dl = ob->curve_cache ? BKE_displist_find(&ob->curve_cache->disp, DL_VERTS) : NULL;
|
||||
float *co = dl ? dl->verts : NULL;
|
||||
BPoint *bp = lt->def;
|
||||
|
||||
@@ -1164,10 +1165,10 @@ static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstra
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ct->tar->path == NULL || ct->tar->path->data == NULL)
|
||||
if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
|
||||
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
||||
|
||||
if (ct->tar->path && ct->tar->path->data) {
|
||||
if (ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) {
|
||||
float quat[4];
|
||||
if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
|
||||
/* animated position along curve depending on time */
|
||||
@@ -1935,7 +1936,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa
|
||||
/* special exception for curves - depsgraph issues */
|
||||
if (ct->tar->type == OB_CURVE) {
|
||||
/* this check is to make sure curve objects get updated on file load correctly.*/
|
||||
if (ct->tar->path == NULL || ct->tar->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
@@ -3011,7 +3012,7 @@ static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bCo
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ct->tar->path == NULL || ct->tar->path->data == NULL)
|
||||
if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
|
||||
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
@@ -3041,7 +3042,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
|
||||
BKE_object_minmax(ct->tar, curveMin, curveMax, TRUE);
|
||||
|
||||
/* get targetmatrix */
|
||||
if (data->tar->path && data->tar->path->data) {
|
||||
if (data->tar->curve_cache && data->tar->curve_cache->path && data->tar->curve_cache->path->data) {
|
||||
float vec[4], dir[3], totmat[4][4];
|
||||
float curvetime;
|
||||
short clamp_axis;
|
||||
@@ -3649,7 +3650,7 @@ static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bC
|
||||
*/
|
||||
|
||||
/* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ct->tar->path == NULL || ct->tar->path->data == NULL)
|
||||
if (ct->tar->curve_cache == NULL || ct->tar->curve_cache->path == NULL || ct->tar->curve_cache->path->data == NULL)
|
||||
BKE_displist_make_curveTypes(cob->scene, ct->tar, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1419,10 +1419,10 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende
|
||||
dl = bevdisp.first;
|
||||
}
|
||||
else {
|
||||
dl = cu->bevobj->disp.first;
|
||||
dl = cu->bevobj->curve_cache ? cu->bevobj->curve_cache->disp.first : NULL;
|
||||
if (dl == NULL) {
|
||||
BKE_displist_make_curveTypes(scene, cu->bevobj, 0);
|
||||
dl = cu->bevobj->disp.first;
|
||||
dl = cu->bevobj->curve_cache->disp.first;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2263,14 +2263,14 @@ void BKE_curve_bevelList_make(Object *ob, bool for_render)
|
||||
/* this function needs an object, because of tflag and upflag */
|
||||
cu = ob->data;
|
||||
|
||||
bev = &ob->bev;
|
||||
bev = &ob->curve_cache->bev;
|
||||
|
||||
/* do we need to calculate the radius for each point? */
|
||||
/* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */
|
||||
|
||||
/* STEP 1: MAKE POLYS */
|
||||
|
||||
BLI_freelistN(&(ob->bev));
|
||||
BLI_freelistN(&(ob->curve_cache->bev));
|
||||
if (cu->editnurb && ob->type != OB_FONT) {
|
||||
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
|
||||
nu = nurbs->first;
|
||||
|
||||
@@ -668,10 +668,10 @@ static float displist_calc_taper(Scene *scene, Object *taperobj, float fac)
|
||||
if (taperobj == NULL || taperobj->type != OB_CURVE)
|
||||
return 1.0;
|
||||
|
||||
dl = taperobj->disp.first;
|
||||
dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
|
||||
if (dl == NULL) {
|
||||
BKE_displist_make_curveTypes(scene, taperobj, 0);
|
||||
dl = taperobj->disp.first;
|
||||
dl = taperobj->curve_cache->disp.first;
|
||||
}
|
||||
if (dl) {
|
||||
float minx, dx, *fp;
|
||||
@@ -713,14 +713,19 @@ void BKE_displist_make_mball(Scene *scene, Object *ob)
|
||||
if (!ob || ob->type != OB_MBALL)
|
||||
return;
|
||||
|
||||
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 MBall");
|
||||
}
|
||||
|
||||
if (ob->type == OB_MBALL) {
|
||||
if (ob == BKE_mball_basis_find(scene, ob)) {
|
||||
BKE_mball_polygonize(scene, ob, &ob->disp, false);
|
||||
BKE_mball_polygonize(scene, ob, &ob->curve_cache->disp, false);
|
||||
BKE_mball_texspace_calc(ob);
|
||||
|
||||
object_deform_mball(ob, &ob->disp);
|
||||
object_deform_mball(ob, &ob->curve_cache->disp);
|
||||
}
|
||||
|
||||
boundbox_displist_object(ob);
|
||||
@@ -1398,10 +1403,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
/* XXX: Temp workaround for depsgraph_mt branch. */
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
|
||||
BLI_freelistN(&(ob->bev));
|
||||
BLI_freelistN(&(ob->curve_cache->bev));
|
||||
|
||||
if (ob->path) free_path(ob->path);
|
||||
ob->path = NULL;
|
||||
if (ob->curve_cache->path) free_path(ob->curve_cache->path);
|
||||
ob->curve_cache->path = NULL;
|
||||
|
||||
if (ob->type == OB_FONT)
|
||||
BKE_vfont_to_curve(G.main, scene, ob, 0);
|
||||
@@ -1420,7 +1425,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
|
||||
}
|
||||
else {
|
||||
float widfac = cu->width - 1.0f;
|
||||
BevList *bl = ob->bev.first;
|
||||
BevList *bl = ob->curve_cache->bev.first;
|
||||
Nurb *nu = nubase->first;
|
||||
|
||||
for (; bl && nu; bl = bl->next, nu = nu->next) {
|
||||
@@ -1627,9 +1632,14 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
|
||||
if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT))
|
||||
return;
|
||||
|
||||
BKE_displist_free(&(ob->disp));
|
||||
dispbase = &(ob->disp);
|
||||
BKE_displist_free(dispbase);
|
||||
if (ob->curve_cache) {
|
||||
BKE_displist_free(&(ob->curve_cache->disp));
|
||||
}
|
||||
else {
|
||||
ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
|
||||
}
|
||||
|
||||
dispbase = &(ob->curve_cache->disp);
|
||||
|
||||
do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco, 0);
|
||||
|
||||
@@ -1712,7 +1722,7 @@ static void boundbox_displist_object(Object *ob)
|
||||
DM_set_object_boundbox(ob, ob->derivedFinal);
|
||||
}
|
||||
else {
|
||||
boundbox_dispbase(ob->bb, &ob->disp);
|
||||
boundbox_dispbase(ob->bb, &ob->curve_cache->disp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
#include "BKE_blender.h"
|
||||
#include "BKE_collision.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_displist.h"
|
||||
@@ -176,10 +177,10 @@ static void precalculate_effector(EffectorCache *eff)
|
||||
if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
|
||||
Curve *cu= eff->ob->data;
|
||||
if (cu->flag & CU_PATH) {
|
||||
if (eff->ob->path==NULL || eff->ob->path->data==NULL)
|
||||
if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
|
||||
BKE_displist_make_curveTypes(eff->scene, eff->ob, 0);
|
||||
|
||||
if (eff->ob->path && eff->ob->path->data) {
|
||||
if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
|
||||
where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL);
|
||||
mul_m4_v3(eff->ob->obmat, eff->guide_loc);
|
||||
mul_mat3_m4_v3(eff->ob->obmat, eff->guide_dir);
|
||||
|
||||
@@ -819,8 +819,10 @@ makebreak:
|
||||
|
||||
cucu->flag |= (CU_PATH + CU_FOLLOW);
|
||||
|
||||
if (cu->textoncurve->path == NULL) BKE_displist_make_curveTypes(scene, cu->textoncurve, 0);
|
||||
if (cu->textoncurve->path) {
|
||||
if (cu->textoncurve->curve_cache == NULL || cu->textoncurve->curve_cache->path == NULL) {
|
||||
BKE_displist_make_curveTypes(scene, cu->textoncurve, 0);
|
||||
}
|
||||
if (cu->textoncurve->curve_cache->path) {
|
||||
float distfac, imat[4][4], imat3[3][3], cmat[3][3];
|
||||
float minx, maxx, miny, maxy;
|
||||
float timeofs, sizefac;
|
||||
@@ -845,7 +847,7 @@ makebreak:
|
||||
/* we put the x-coordinaat exact at the curve, the y is rotated */
|
||||
|
||||
/* length correction */
|
||||
distfac = sizefac * cu->textoncurve->path->totdist / (maxx - minx);
|
||||
distfac = sizefac * cu->textoncurve->curve_cache->path->totdist / (maxx - minx);
|
||||
timeofs = 0.0f;
|
||||
|
||||
if (distfac > 1.0f) {
|
||||
|
||||
@@ -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(<Ob->disp);
|
||||
BKE_displist_free(<Ob->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;
|
||||
@@ -511,7 +512,7 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir
|
||||
int cycl = 0;
|
||||
|
||||
/* test for cyclic */
|
||||
bl = ob->bev.first;
|
||||
bl = ob->curve_cache->bev.first;
|
||||
if (!bl->nr) return 0;
|
||||
if (bl->poly > -1) cycl = 1;
|
||||
|
||||
@@ -526,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 = ob->path;
|
||||
Path *path = ob->curve_cache->path;
|
||||
float dvec[3];
|
||||
|
||||
if (ctime < 0.0f) {
|
||||
@@ -564,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 (par->path == NULL) {
|
||||
if (ELEM(NULL, par->curve_cache, par->curve_cache->path)) {
|
||||
BKE_displist_make_curveTypes(scene, par, 0);
|
||||
if (par->path == NULL) return 0; // happens on append...
|
||||
if (par->curve_cache->path == NULL) return 0; // happens on append...
|
||||
}
|
||||
|
||||
/* options */
|
||||
@@ -575,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]) / (par->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]) / (par->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 */
|
||||
@@ -995,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);
|
||||
@@ -1021,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1275,7 +1275,9 @@ int object_remove_material_slot(Object *ob)
|
||||
/* check indices from mesh */
|
||||
if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
|
||||
data_delete_material_index_id((ID *)ob->data, actcol - 1);
|
||||
BKE_displist_free(&ob->disp);
|
||||
if (ob->curve_cache) {
|
||||
BKE_displist_free(&ob->curve_cache->disp);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
|
||||
/* #include "BKE_object.h" */
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_scene.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_displist.h"
|
||||
@@ -366,7 +367,7 @@ void BKE_mball_texspace_calc(Object *ob)
|
||||
(min)[0] = (min)[1] = (min)[2] = 1.0e30f;
|
||||
(max)[0] = (max)[1] = (max)[2] = -1.0e30f;
|
||||
|
||||
dl = ob->disp.first;
|
||||
dl = ob->curve_cache->disp.first;
|
||||
while (dl) {
|
||||
tot = dl->nr;
|
||||
if (tot) do_it = TRUE;
|
||||
|
||||
@@ -1292,7 +1292,13 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
|
||||
MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly,
|
||||
int *totloop, int *totpoly)
|
||||
{
|
||||
return BKE_mesh_nurbs_displist_to_mdata(ob, &ob->disp,
|
||||
ListBase disp = {NULL};
|
||||
|
||||
if (ob->curve_cache) {
|
||||
disp = ob->curve_cache->disp;
|
||||
}
|
||||
|
||||
return BKE_mesh_nurbs_displist_to_mdata(ob, &disp,
|
||||
allvert, totvert,
|
||||
alledge, totedge,
|
||||
allloop, allpoly, NULL,
|
||||
@@ -1638,8 +1644,13 @@ void BKE_mesh_from_nurbs(Object *ob)
|
||||
{
|
||||
Curve *cu = (Curve *) ob->data;
|
||||
bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
|
||||
ListBase disp = {NULL};
|
||||
|
||||
BKE_mesh_from_nurbs_displist(ob, &ob->disp, use_orco_uv);
|
||||
if (ob->curve_cache) {
|
||||
disp = ob->curve_cache->disp;
|
||||
}
|
||||
|
||||
BKE_mesh_from_nurbs_displist(ob, &disp, use_orco_uv);
|
||||
}
|
||||
|
||||
typedef struct EdgeLink {
|
||||
|
||||
@@ -170,6 +170,19 @@ void BKE_object_free_bulletsoftbody(Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_object_free_curve_cache(Object *ob)
|
||||
{
|
||||
if (ob->curve_cache) {
|
||||
BKE_displist_free(&ob->curve_cache->disp);
|
||||
BLI_freelistN(&ob->curve_cache->bev);
|
||||
if (ob->curve_cache->path) {
|
||||
free_path(ob->curve_cache->path);
|
||||
}
|
||||
MEM_freeN(ob->curve_cache);
|
||||
ob->curve_cache = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_object_free_modifiers(Object *ob)
|
||||
{
|
||||
while (ob->modifiers.first) {
|
||||
@@ -270,7 +283,9 @@ void BKE_object_free_derived_caches(Object *ob)
|
||||
ob->derivedDeform = NULL;
|
||||
}
|
||||
|
||||
BKE_displist_free(&ob->disp);
|
||||
if (ob->curve_cache) {
|
||||
BKE_displist_free(&ob->curve_cache->disp);
|
||||
}
|
||||
}
|
||||
|
||||
/* do not free object itself */
|
||||
@@ -342,9 +357,12 @@ void BKE_object_free(Object *ob)
|
||||
if (ob->pc_ids.first) BLI_freelistN(&ob->pc_ids);
|
||||
|
||||
/* Free runtime curves data. */
|
||||
BLI_freelistN(&ob->bev);
|
||||
if (ob->path)
|
||||
free_path(ob->path);
|
||||
if (ob->curve_cache) {
|
||||
BLI_freelistN(&ob->curve_cache->bev);
|
||||
if (ob->curve_cache->path)
|
||||
free_path(ob->curve_cache->path);
|
||||
MEM_freeN(ob->curve_cache);
|
||||
}
|
||||
}
|
||||
|
||||
static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Object **obpoin)
|
||||
@@ -1255,8 +1273,6 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
|
||||
|
||||
for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]);
|
||||
|
||||
obn->disp.first = obn->disp.last = NULL;
|
||||
|
||||
if (ob->pd) {
|
||||
obn->pd = MEM_dupallocN(ob->pd);
|
||||
if (obn->pd->tex)
|
||||
@@ -1280,8 +1296,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
|
||||
obn->mpath = NULL;
|
||||
|
||||
/* Copy runtime surve data. */
|
||||
obn->bev.first = obn->bev.last = NULL;
|
||||
obn->path = NULL;
|
||||
obn->curve_cache = NULL;
|
||||
|
||||
return obn;
|
||||
}
|
||||
@@ -1760,9 +1775,9 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
|
||||
unit_m4(mat);
|
||||
|
||||
cu = par->data;
|
||||
if (par->path == NULL || par->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (ELEM3(NULL, par->curve_cache, par->curve_cache->path, par->curve_cache->path->data)) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
BKE_displist_make_curveTypes(scene, par, 0);
|
||||
if (par->path == NULL) return;
|
||||
if (par->curve_cache->path == NULL) return;
|
||||
|
||||
/* catch exceptions: feature for nla stride editing */
|
||||
if (ob->ipoflag & OB_DISABLE_PATH) {
|
||||
@@ -1793,7 +1808,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[4][4])
|
||||
|
||||
/* time calculus is correct, now apply distance offset */
|
||||
if (cu->flag & CU_OFFS_PATHDIST) {
|
||||
ctime += timeoffs / par->path->totdist;
|
||||
ctime += timeoffs / par->curve_cache->path->totdist;
|
||||
|
||||
/* restore */
|
||||
SWAP(float, sf_orig, ob->sf);
|
||||
@@ -1950,7 +1965,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
|
||||
}
|
||||
else if (par->type == OB_LATTICE) {
|
||||
Lattice *latt = par->data;
|
||||
DispList *dl = BKE_displist_find(&par->disp, DL_VERTS);
|
||||
DispList *dl = par->curve_cache ? BKE_displist_find(&par->curve_cache->disp, DL_VERTS) : NULL;
|
||||
float (*co)[3] = dl ? (float (*)[3])dl->verts : NULL;
|
||||
int tot;
|
||||
|
||||
@@ -2503,10 +2518,10 @@ void BKE_object_foreach_display_point(
|
||||
func_cb(co, user_data);
|
||||
}
|
||||
}
|
||||
else if (ob->disp.first) {
|
||||
else if (ob->curve_cache && ob->curve_cache->disp.first) {
|
||||
DispList *dl;
|
||||
|
||||
for (dl = ob->disp.first; dl; dl = dl->next) {
|
||||
for (dl = ob->curve_cache->disp.first; dl; dl = dl->next) {
|
||||
float *v3 = dl->verts;
|
||||
int totvert = dl->nr;
|
||||
int i;
|
||||
|
||||
@@ -4818,8 +4818,6 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
ob->mode &= ~(OB_MODE_EDIT | OB_MODE_PARTICLE_EDIT);
|
||||
}
|
||||
|
||||
ob->disp.first = ob->disp.last = NULL;
|
||||
|
||||
ob->adt = newdataadr(fd, ob->adt);
|
||||
direct_link_animdata(fd, ob->adt);
|
||||
|
||||
@@ -5015,8 +5013,7 @@ static void direct_link_object(FileData *fd, Object *ob)
|
||||
link_list(fd, &ob->pc_ids);
|
||||
|
||||
/* Runtime curve data */
|
||||
ob->bev.first = ob->bev.last = NULL;
|
||||
ob->path = NULL;
|
||||
ob->curve_cache = NULL;
|
||||
|
||||
/* in case this value changes in future, clamp else we get undefined behavior */
|
||||
CLAMP(ob->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
|
||||
|
||||
@@ -1244,7 +1244,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
|
||||
|
||||
ob->parent = NULL;
|
||||
ob->constraints.first = ob->constraints.last = NULL;
|
||||
ob->disp.first = ob->disp.last = NULL;
|
||||
ob->curve_cache = NULL;
|
||||
ob->transflag &= ~OB_DUPLI;
|
||||
ob->lay = base->lay;
|
||||
|
||||
@@ -1386,7 +1386,7 @@ static EnumPropertyItem convert_target_items[] = {
|
||||
|
||||
static void curvetomesh(Scene *scene, Object *ob)
|
||||
{
|
||||
if (ob->disp.first == NULL)
|
||||
if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first))
|
||||
BKE_displist_make_curveTypes(scene, ob, 0); /* force creation */
|
||||
|
||||
BKE_mesh_from_nurbs(ob); /* also does users */
|
||||
@@ -1554,7 +1554,7 @@ static int convert_exec(bContext *C, wmOperator *op)
|
||||
|
||||
cu = newob->data;
|
||||
|
||||
if (!newob->disp.first)
|
||||
if ( !newob->curve_cache || !newob->curve_cache->disp.first)
|
||||
BKE_displist_make_curveTypes(scene, newob, 0);
|
||||
|
||||
newob->type = OB_CURVE;
|
||||
@@ -1596,7 +1596,7 @@ static int convert_exec(bContext *C, wmOperator *op)
|
||||
curvetomesh(scene, newob);
|
||||
|
||||
/* meshes doesn't use displist */
|
||||
BKE_displist_free(&newob->disp);
|
||||
BKE_object_free_curve_cache(newob);
|
||||
}
|
||||
}
|
||||
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
|
||||
@@ -1617,7 +1617,7 @@ static int convert_exec(bContext *C, wmOperator *op)
|
||||
newob = ob;
|
||||
|
||||
/* meshes doesn't use displist */
|
||||
BKE_displist_free(&newob->disp);
|
||||
BKE_object_free_curve_cache(newob);
|
||||
}
|
||||
|
||||
curvetomesh(scene, newob);
|
||||
@@ -1636,7 +1636,7 @@ static int convert_exec(bContext *C, wmOperator *op)
|
||||
ob->flag |= OB_DONE;
|
||||
}
|
||||
|
||||
if (!baseob->disp.first) {
|
||||
if (!baseob->curve_cache || !baseob->curve_cache->disp.first) {
|
||||
BKE_displist_make_mball(scene, baseob);
|
||||
}
|
||||
|
||||
@@ -1659,7 +1659,7 @@ static int convert_exec(bContext *C, wmOperator *op)
|
||||
for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]);
|
||||
}
|
||||
|
||||
BKE_mesh_from_metaball(&baseob->disp, newob->data);
|
||||
BKE_mesh_from_metaball(&baseob->curve_cache->disp, newob->data);
|
||||
|
||||
if (obact->type == OB_MBALL) {
|
||||
basact = basen;
|
||||
|
||||
@@ -115,8 +115,8 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
|
||||
{
|
||||
int totv = 0, totf = 0, tottri = 0;
|
||||
|
||||
if (ob->disp.first)
|
||||
BKE_displist_count(&ob->disp, &totv, &totf, &tottri);
|
||||
if (ob->curve_cache && ob->curve_cache->disp.first)
|
||||
BKE_displist_count(&ob->curve_cache->disp, &totv, &totf, &tottri);
|
||||
|
||||
totv *= totob;
|
||||
totf *= totob;
|
||||
|
||||
@@ -1900,9 +1900,9 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
|
||||
const bool is_edit = (lt->editlatt != NULL);
|
||||
|
||||
/* now we default make displist, this will modifiers work for non animated case */
|
||||
if (ob->disp.first == NULL)
|
||||
if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first))
|
||||
BKE_lattice_modifiers_calc(scene, ob);
|
||||
dl = BKE_displist_find(&ob->disp, DL_VERTS);
|
||||
dl = BKE_displist_find(&ob->curve_cache->disp, DL_VERTS);
|
||||
|
||||
if (is_edit) {
|
||||
lt = lt->editlatt->latt;
|
||||
@@ -3885,7 +3885,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
|
||||
case OB_CURVE:
|
||||
cu = ob->data;
|
||||
|
||||
lb = &ob->disp;
|
||||
lb = &ob->curve_cache->disp;
|
||||
|
||||
if (solid) {
|
||||
dl = lb->first;
|
||||
@@ -3935,7 +3935,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
|
||||
break;
|
||||
case OB_SURF:
|
||||
|
||||
lb = &ob->disp;
|
||||
lb = &ob->curve_cache->disp;
|
||||
|
||||
if (solid) {
|
||||
dl = lb->first;
|
||||
@@ -3963,8 +3963,11 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
|
||||
case OB_MBALL:
|
||||
|
||||
if (BKE_mball_is_basis(ob)) {
|
||||
lb = &ob->disp;
|
||||
if (lb->first == NULL) BKE_displist_make_mball(scene, ob);
|
||||
lb = ob->curve_cache ? &ob->curve_cache->disp : NULL;
|
||||
if (lb->first == NULL) {
|
||||
BKE_displist_make_mball(scene, ob);
|
||||
lb = &ob->curve_cache->disp;
|
||||
}
|
||||
if (lb->first == NULL) {
|
||||
return true;
|
||||
}
|
||||
@@ -5554,7 +5557,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
||||
if ((cu->flag & CU_3D) && (ts->normalsize > 0.0015f) && (cu->drawflag & CU_HIDE_NORMALS) == 0) {
|
||||
|
||||
UI_ThemeColor(TH_WIRE_EDIT);
|
||||
for (bl = ob->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
|
||||
for (bl = ob->curve_cache->bev.first, nu = nurb; nu && bl; bl = bl->next, nu = nu->next) {
|
||||
BevPoint *bevp = (BevPoint *)(bl + 1);
|
||||
int nr = bl->nr;
|
||||
int skip = nu->resolu / 16;
|
||||
@@ -5977,7 +5980,7 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d,
|
||||
}
|
||||
else if (pd->forcefield == PFIELD_GUIDE && ob->type == OB_CURVE) {
|
||||
Curve *cu = ob->data;
|
||||
if ((cu->flag & CU_PATH) && ob->path && ob->path->data) {
|
||||
if ((cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
|
||||
float mindist, guidevec1[4], guidevec2[3];
|
||||
|
||||
//if (has_ipo_code(ob->ipo, OB_PD_FSTR))
|
||||
@@ -6242,7 +6245,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
||||
has_faces = dm->getNumTessFaces(dm);
|
||||
}
|
||||
else {
|
||||
has_faces = BKE_displist_has_faces(&ob->disp);
|
||||
has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
|
||||
}
|
||||
|
||||
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
|
||||
@@ -6251,7 +6254,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
||||
draw_mesh_object_outline(v3d, ob, dm);
|
||||
}
|
||||
else {
|
||||
drawDispListwire(&ob->disp);
|
||||
drawDispListwire(&ob->curve_cache->disp);
|
||||
}
|
||||
draw_index_wire = true;
|
||||
}
|
||||
@@ -6259,7 +6262,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
||||
else if (ob->type == OB_MBALL) {
|
||||
if (BKE_mball_is_basis(ob)) {
|
||||
if ((base->flag & OB_FROMDUPLI) == 0)
|
||||
drawDispListwire(&ob->disp);
|
||||
drawDispListwire(&ob->curve_cache->disp);
|
||||
}
|
||||
}
|
||||
else if (ob->type == OB_ARMATURE) {
|
||||
@@ -6294,7 +6297,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
|
||||
drawCurveDMWired(ob);
|
||||
}
|
||||
else {
|
||||
drawDispListwire(&ob->disp);
|
||||
drawDispListwire(&ob->curve_cache->disp);
|
||||
}
|
||||
|
||||
if (ob->type == OB_CURVE)
|
||||
@@ -6303,7 +6306,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
|
||||
}
|
||||
else if (ob->type == OB_MBALL) {
|
||||
if (BKE_mball_is_basis(ob)) {
|
||||
drawDispListwire(&ob->disp);
|
||||
drawDispListwire(&ob->curve_cache->disp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6613,7 +6616,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
|
||||
/* bad exception, solve this! otherwise outline shows too late */
|
||||
if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
|
||||
/* still needed for curves hidden in other layers. depgraph doesnt handle that yet */
|
||||
if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0);
|
||||
if (ELEM(NULL, ob->curve_cache, ob->curve_cache->disp.first)) {
|
||||
BKE_displist_make_curveTypes(scene, ob, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* draw outline for selected objects, mesh does itself */
|
||||
|
||||
@@ -368,7 +368,7 @@ void lattice_foreachScreenVert(
|
||||
Object *obedit = vc->obedit;
|
||||
Lattice *lt = obedit->data;
|
||||
BPoint *bp = lt->editlatt->latt->def;
|
||||
DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS);
|
||||
DispList *dl = obedit->curve_cache ? BKE_displist_find(&obedit->curve_cache->disp, DL_VERTS) : NULL;
|
||||
float *co = dl ? dl->verts : NULL;
|
||||
int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@ typedef struct Object {
|
||||
|
||||
ListBase constraintChannels DNA_DEPRECATED; // XXX deprecated... old animation system
|
||||
ListBase effect DNA_DEPRECATED; // XXX deprecated... keep for readfile
|
||||
ListBase disp; /* list of DispList, used by lattice, metaballs curve & surfaces */
|
||||
ListBase defbase; /* list of bDeformGroup (vertex groups) names and flag only */
|
||||
ListBase modifiers; /* list of ModifierData structures */
|
||||
|
||||
@@ -277,8 +276,8 @@ typedef struct Object {
|
||||
|
||||
float ima_ofs[2]; /* offset for image empties */
|
||||
|
||||
struct Path *path;
|
||||
ListBase bev;
|
||||
/* Runtime valuated curve-specific data, not stored in the file */
|
||||
struct CurveCache *curve_cache;
|
||||
} Object;
|
||||
|
||||
/* Warning, this is not used anymore because hooks are now modifiers */
|
||||
|
||||
@@ -359,8 +359,13 @@ Mesh *rna_Main_meshes_new_from_object(
|
||||
BKE_mesh_from_metaball(&disp, tmpmesh);
|
||||
BKE_displist_free(&disp);
|
||||
}
|
||||
else
|
||||
BKE_mesh_from_metaball(&ob->disp, tmpmesh);
|
||||
else {
|
||||
ListBase disp = {NULL, NULL};
|
||||
if (ob->curve_cache) {
|
||||
disp = ob->curve_cache->disp;
|
||||
}
|
||||
BKE_mesh_from_metaball(&disp, tmpmesh);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
|
||||
#include "BKE_cdderivedmesh.h"
|
||||
#include "BKE_displist.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_modifier.h"
|
||||
#include "BKE_object.h"
|
||||
@@ -387,12 +388,12 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
|
||||
BKE_object_to_mat3(amd->curve_ob, tmp_mat);
|
||||
scale = mat3_to_scale(tmp_mat);
|
||||
|
||||
if (!amd->curve_ob->path) {
|
||||
if (!amd->curve_ob->curve_cache || !amd->curve_ob->curve_cache->path) {
|
||||
cu->flag |= CU_PATH; // needed for path & bevlist
|
||||
BKE_displist_make_curveTypes(scene, amd->curve_ob, 0);
|
||||
}
|
||||
if (amd->curve_ob->path)
|
||||
length = scale * amd->curve_ob->path->totdist;
|
||||
if (amd->curve_ob->curve_cache->path)
|
||||
length = scale * amd->curve_ob->curve_cache->path->totdist;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user