Cleanup/Refactor: Move CurveCache runtime data into Object.runtime struct.
authorBastien Montagne <montagne29@wanadoo.fr>
Mon, 30 Jul 2018 14:54:40 +0000 (16:54 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Mon, 30 Jul 2018 14:58:44 +0000 (16:58 +0200)
Also, fix missing cleanup of Object.runtime when copying Object
datablocks!

27 files changed:
source/blender/alembic/intern/abc_mball.cc
source/blender/alembic/intern/abc_nurbs.cc
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/armature_update.c
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/effect.c
source/blender/blenkernel/intern/font.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh_convert.c
source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache_impl_metaball.c
source/blender/draw/modes/object_mode.c
source/blender/editors/curve/editcurve.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_relations.c
source/blender/editors/space_info/info_stats.c
source/blender/editors/space_view3d/view3d_iterators.c
source/blender/makesdna/DNA_object_types.h
source/blender/modifiers/intern/MOD_array.c

index d6e54407922f75854dd6cf9ae07488a6817939ba..62ab561274acf8dd7dd2a951504e6169c0045a1d 100644 (file)
@@ -52,7 +52,7 @@ AbcMBallWriter::AbcMBallWriter(
        m_is_animated = isAnimated();
 
        m_mesh_ob = BKE_object_copy(bmain, ob);
-       m_mesh_ob->curve_cache = (CurveCache *)MEM_callocN(
+       m_mesh_ob->runtime.curve_cache = (CurveCache *)MEM_callocN(
                                     sizeof(CurveCache),
                                     "CurveCache for AbcMBallWriter");
 
index 95d06fc5efe01155242a75d9b8ca31e667ecf417..bf41b44e4183a2b3af8fb3920b9792de2775582d 100644 (file)
@@ -130,8 +130,8 @@ void AbcNurbsWriter::do_write()
        Curve *curve = static_cast<Curve *>(m_object->data);
        ListBase *nulb;
 
-       if (m_object->curve_cache->deformed_nurbs.first != NULL) {
-               nulb = &m_object->curve_cache->deformed_nurbs;
+       if (m_object->runtime.curve_cache->deformed_nurbs.first != NULL) {
+               nulb = &m_object->runtime.curve_cache->deformed_nurbs;
        }
        else {
                nulb = BKE_curve_nurbs_get(curve);
index a867accfe443172863817eb5d6d85a12a7489e99..7df889d22b272801ef15a597e9bb69b2a70e4aa5 100644 (file)
@@ -537,18 +537,18 @@ void calc_curvepath(Object *ob, ListBase *nurbs)
                return;
        }
 
-       if (ob->curve_cache->path) free_path(ob->curve_cache->path);
-       ob->curve_cache->path = NULL;
+       if (ob->runtime.curve_cache->path) free_path(ob->runtime.curve_cache->path);
+       ob->runtime.curve_cache->path = NULL;
 
        /* weak! can only use first curve */
-       bl = ob->curve_cache->bev.first;
+       bl = ob->runtime.curve_cache->bev.first;
        if (bl == NULL || !bl->nr) {
                return;
        }
 
        nu = nurbs->first;
 
-       ob->curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
+       ob->runtime.curve_cache->path = path = MEM_callocN(sizeof(Path), "calc_curvepath");
 
        /* if POLY: last vertice != first vertice */
        cycl = (bl->poly != -1);
@@ -665,15 +665,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->curve_cache == NULL || ob->curve_cache->path == NULL || ob->curve_cache->path->data == NULL) {
+       if (ob->runtime.curve_cache == NULL || ob->runtime.curve_cache->path == NULL || ob->runtime.curve_cache->path->data == NULL) {
                printf("no path!\n");
                return 0;
        }
-       path = ob->curve_cache->path;
+       path = ob->runtime.curve_cache->path;
        pp = path->data;
 
        /* test for cyclic */
-       bl = ob->curve_cache->bev.first;
+       bl = ob->runtime.curve_cache->bev.first;
        if (!bl) return 0;
        if (!bl->nr) return 0;
        if (bl->poly > -1) cycl = 1;
index 628f92c78032a36d913b6a9542b782cf4355482c..26fbd22c67e0ff136bbebfd8943e28f424042b71 100644 (file)
@@ -201,7 +201,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->curve_cache->path->totdist;
+               splineLen = ikData->tar->runtime.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
index 72a1f941c26a0955b368ab8079c8397e4108f602..3f50321b4d5452d4d3911046a73d779acd6d2fca 100644 (file)
@@ -655,8 +655,8 @@ DerivedMesh *CDDM_from_curve(Object *ob)
 {
        ListBase disp = {NULL, NULL};
 
-       if (ob->curve_cache) {
-               disp = ob->curve_cache->disp;
+       if (ob->runtime.curve_cache) {
+               disp = ob->runtime.curve_cache->disp;
        }
 
        return CDDM_from_curve_displist(ob, &disp);
index 5aa192d527ab729d04866bd449dfd8fc6d506167..ef412f0006e3abfefa9dc08633538664e0844e94 100644 (file)
@@ -496,7 +496,7 @@ static void contarget_get_lattice_mat(Object *ob, const char *substring, float m
 {
        Lattice *lt = (Lattice *)ob->data;
 
-       DispList *dl = ob->curve_cache ? BKE_displist_find(&ob->curve_cache->disp, DL_VERTS) : NULL;
+       DispList *dl = ob->runtime.curve_cache ? BKE_displist_find(&ob->runtime.curve_cache->disp, DL_VERTS) : NULL;
        const float *co = dl ? dl->verts : NULL;
        BPoint *bp = lt->def;
 
@@ -1266,7 +1266,7 @@ static void followpath_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
                 *              currently for paths to work it needs to go through the bevlist/displist system (ton)
                 */
 
-               if (ct->tar->curve_cache && ct->tar->curve_cache->path && ct->tar->curve_cache->path->data) {
+               if (ct->tar->runtime.curve_cache && ct->tar->runtime.curve_cache->path && ct->tar->runtime.curve_cache->path->data) {
                        float quat[4];
                        if ((data->followflag & FOLLOWPATH_STATIC) == 0) {
                                /* animated position along curve depending on time */
@@ -2037,7 +2037,7 @@ static void pycon_get_tarmat(struct Depsgraph *UNUSED(depsgraph),
 #endif
 
        if (VALID_CONS_TARGET(ct)) {
-               if (ct->tar->type == OB_CURVE && ct->tar->curve_cache == NULL) {
+               if (ct->tar->type == OB_CURVE && ct->tar->runtime.curve_cache == NULL) {
                        unit_m4(ct->matrix);
                        return;
                }
@@ -3104,7 +3104,7 @@ static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
                BKE_object_minmax(ct->tar, curveMin, curveMax, true);
 
                /* get targetmatrix */
-               if (data->tar->curve_cache &&  data->tar->curve_cache->path && data->tar->curve_cache->path->data) {
+               if (data->tar->runtime.curve_cache &&  data->tar->runtime.curve_cache->path && data->tar->runtime.curve_cache->path->data) {
                        float vec[4], dir[3], totmat[4][4];
                        float curvetime;
                        short clamp_axis;
index 33a24f7793713be261d09613bdaebb3926f5c0a6..39b285402059985d3db602bbdcad7e07ecb3bdb8 100644 (file)
@@ -1752,11 +1752,11 @@ void BKE_curve_bevel_make(
                                BKE_displist_make_curveTypes_forRender(depsgraph, scene, cu->bevobj, &bevdisp, NULL, false, use_render_resolution);
                                dl = bevdisp.first;
                        }
-                       else if (cu->bevobj->curve_cache) {
-                               dl = cu->bevobj->curve_cache->disp.first;
+                       else if (cu->bevobj->runtime.curve_cache) {
+                               dl = cu->bevobj->runtime.curve_cache->disp.first;
                        }
                        else {
-                               BLI_assert(cu->bevobj->curve_cache != NULL);
+                               BLI_assert(cu->bevobj->runtime.curve_cache != NULL);
                                dl = NULL;
                        }
 
@@ -2669,14 +2669,14 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render)
                ELEM(cu->bevfac2_mapping, CU_BEVFAC_MAP_SEGMENT, CU_BEVFAC_MAP_SPLINE);
 
 
-       bev = &ob->curve_cache->bev;
+       bev = &ob->runtime.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  */
 
-       BKE_curve_bevelList_free(&ob->curve_cache->bev);
+       BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
        nu = nurbs->first;
        if (cu->editnurb && ob->type != OB_FONT) {
                is_editmode = 1;
index 34fd32b2908de46923ecc527125f1b7fa8b67a65..562e2257ea0918b1e79dfdbfd25f7fd3024465e6 100644 (file)
@@ -692,10 +692,10 @@ static float displist_calc_taper(Depsgraph *depsgraph, Scene *scene, Object *tap
        if (taperobj == NULL || taperobj->type != OB_CURVE)
                return 1.0;
 
-       dl = taperobj->curve_cache ? taperobj->curve_cache->disp.first : NULL;
+       dl = taperobj->runtime.curve_cache ? taperobj->runtime.curve_cache->disp.first : NULL;
        if (dl == NULL) {
                BKE_displist_make_curveTypes(depsgraph, scene, taperobj, 0);
-               dl = taperobj->curve_cache->disp.first;
+               dl = taperobj->runtime.curve_cache->disp.first;
        }
        if (dl) {
                float minx, dx, *fp;
@@ -738,17 +738,17 @@ void BKE_displist_make_mball(Depsgraph *depsgraph, Scene *scene, Object *ob)
                return;
 
        if (ob == BKE_mball_basis_find(scene, ob)) {
-               if (ob->curve_cache) {
-                       BKE_displist_free(&(ob->curve_cache->disp));
+               if (ob->runtime.curve_cache) {
+                       BKE_displist_free(&(ob->runtime.curve_cache->disp));
                }
                else {
-                       ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for MBall");
+                       ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for MBall");
                }
 
-               BKE_mball_polygonize(depsgraph, scene, ob, &ob->curve_cache->disp);
+               BKE_mball_polygonize(depsgraph, scene, ob, &ob->runtime.curve_cache->disp);
                BKE_mball_texspace_calc(ob);
 
-               object_deform_mball(ob, &ob->curve_cache->disp);
+               object_deform_mball(ob, &ob->runtime.curve_cache->disp);
 
                /* NOP for MBALLs anyway... */
                boundbox_displist_object(ob);
@@ -1314,7 +1314,7 @@ void BKE_displist_make_surf(
        }
 
        if (!for_orco) {
-               BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
+               BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
                curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final,
                                          for_render, use_render_resolution);
        }
@@ -1558,15 +1558,15 @@ static void do_makeDispListCurveTypes(
                ListBase dlbev;
                ListBase nubase = {NULL, NULL};
 
-               BKE_curve_bevelList_free(&ob->curve_cache->bev);
+               BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
 
                /* We only re-evaluate path if evaluation is not happening for orco.
                 * If the calculation happens for orco, we should never free data which
                 * was needed before and only not needed for orco calculation.
                 */
                if (!for_orco) {
-                       if (ob->curve_cache->path) free_path(ob->curve_cache->path);
-                       ob->curve_cache->path = NULL;
+                       if (ob->runtime.curve_cache->path) free_path(ob->runtime.curve_cache->path);
+                       ob->runtime.curve_cache->path = NULL;
                }
 
                if (ob->type == OB_FONT) {
@@ -1590,7 +1590,7 @@ static void do_makeDispListCurveTypes(
                }
                else {
                        float widfac = cu->width - 1.0f;
-                       BevList *bl = ob->curve_cache->bev.first;
+                       BevList *bl = ob->runtime.curve_cache->bev.first;
                        Nurb *nu = nubase.first;
 
                        for (; bl && nu; bl = bl->next, nu = nu->next) {
@@ -1777,7 +1777,7 @@ static void do_makeDispListCurveTypes(
                }
 
                if (!for_orco) {
-                       BKE_nurbList_duplicate(&ob->curve_cache->deformed_nurbs, &nubase);
+                       BKE_nurbList_duplicate(&ob->runtime.curve_cache->deformed_nurbs, &nubase);
                        curve_calc_modifiers_post(depsgraph, scene, ob, &nubase, dispbase, r_dm_final, for_render, use_render_resolution);
                }
 
@@ -1801,11 +1801,11 @@ void BKE_displist_make_curveTypes(Depsgraph *depsgraph, Scene *scene, Object *ob
 
        BKE_object_free_derived_caches(ob);
 
-       if (!ob->curve_cache) {
-               ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
+       if (!ob->runtime.curve_cache) {
+               ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
        }
 
-       dispbase = &(ob->curve_cache->disp);
+       dispbase = &(ob->runtime.curve_cache->disp);
 
        do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, &ob->derivedFinal, 0, for_orco, 0);
 
@@ -1817,8 +1817,8 @@ void BKE_displist_make_curveTypes_forRender(
         DerivedMesh **r_dm_final, const bool for_orco,
         const bool use_render_resolution)
 {
-       if (ob->curve_cache == NULL) {
-               ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
+       if (ob->runtime.curve_cache == NULL) {
+               ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
        }
 
        do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, r_dm_final, true, for_orco, use_render_resolution);
@@ -1827,8 +1827,8 @@ void BKE_displist_make_curveTypes_forRender(
 void BKE_displist_make_curveTypes_forOrco(
         Depsgraph *depsgraph, Scene *scene, Object *ob, ListBase *dispbase)
 {
-       if (ob->curve_cache == NULL) {
-               ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
+       if (ob->runtime.curve_cache == NULL) {
+               ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for Curve");
        }
 
        do_makeDispListCurveTypes(depsgraph, scene, ob, dispbase, NULL, 1, 1, 1);
@@ -1903,7 +1903,7 @@ static void boundbox_displist_object(Object *ob)
                        float min[3], max[3];
 
                        INIT_MINMAX(min, max);
-                       BKE_displist_minmax(&ob->curve_cache->disp, min, max);
+                       BKE_displist_minmax(&ob->runtime.curve_cache->disp, min, max);
                        BKE_boundbox_init_from_minmax(ob->bb, min, max);
 
                        ob->bb->flag &= ~BOUNDBOX_DIRTY;
index b6eb26443ea4f8aef11d33c51d715acfe619c6b9..52ea4bf4a5eaf3de7f56abd8d24ae7ef9901b18a 100644 (file)
@@ -163,10 +163,10 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef
        if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) {
                Curve *cu= eff->ob->data;
                if (cu->flag & CU_PATH) {
-                       if (eff->ob->curve_cache == NULL || eff->ob->curve_cache->path==NULL || eff->ob->curve_cache->path->data==NULL)
+                       if (eff->ob->runtime.curve_cache == NULL || eff->ob->runtime.curve_cache->path==NULL || eff->ob->runtime.curve_cache->path->data==NULL)
                                BKE_displist_make_curveTypes(depsgraph, eff->scene, eff->ob, 0);
 
-                       if (eff->ob->curve_cache->path && eff->ob->curve_cache->path->data) {
+                       if (eff->ob->runtime.curve_cache->path && eff->ob->runtime.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);
index 36633663f9d03090c072423750ecaae9c0e27c7b..b5fba6d30e80e365343f506cc145fc521f563128 100644 (file)
@@ -1075,8 +1075,8 @@ makebreak:
        /* TEXT ON CURVE */
        /* Note: Only OB_CURVE objects could have a path  */
        if (cu->textoncurve && cu->textoncurve->type == OB_CURVE) {
-               BLI_assert(cu->textoncurve->curve_cache != NULL);
-               if (cu->textoncurve->curve_cache->path) {
+               BLI_assert(cu->textoncurve->runtime.curve_cache != NULL);
+               if (cu->textoncurve->runtime.curve_cache->path) {
                        float distfac, imat[4][4], imat3[3][3], cmat[3][3];
                        float minx, maxx, miny, maxy;
                        float timeofs, sizefac;
@@ -1106,7 +1106,7 @@ makebreak:
                        /* we put the x-coordinaat exact at the curve, the y is rotated */
 
                        /* length correction */
-                       distfac = sizefac * cu->textoncurve->curve_cache->path->totdist / (maxx - minx);
+                       distfac = sizefac * cu->textoncurve->runtime.curve_cache->path->totdist / (maxx - minx);
                        timeofs = 0.0f;
 
                        if (distfac > 1.0f) {
index 78ff43c2981c1bbed55fae724357db8557630b0c..04830eb108184b2f63e90424a765b2ab324ea6a4 100644 (file)
@@ -211,9 +211,9 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
                /* works best if we force to linear type (endpoints match) */
                lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
 
-               if (ltOb->curve_cache) {
+               if (ltOb->runtime.curve_cache) {
                        /* prevent using deformed locations */
-                       BKE_displist_free(&ltOb->curve_cache->disp);
+                       BKE_displist_free(&ltOb->runtime.curve_cache->disp);
                }
 
                copy_m4_m4(mat, ltOb->obmat);
@@ -349,7 +349,7 @@ LatticeDeformData *init_latt_deform(Object *oblatt, Object *ob)
        /* we make an array with all differences */
        Lattice *lt = oblatt->data;
        BPoint *bp;
-       DispList *dl = oblatt->curve_cache ? BKE_displist_find(&oblatt->curve_cache->disp, DL_VERTS) : NULL;
+       DispList *dl = oblatt->runtime.curve_cache ? BKE_displist_find(&oblatt->runtime.curve_cache->disp, DL_VERTS) : NULL;
        const float *co = dl ? dl->verts : NULL;
        float *fp, imat[4][4];
        float fu, fv, fw;
@@ -558,7 +558,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
        int cycl = 0;
 
        /* test for cyclic */
-       bl = ob->curve_cache->bev.first;
+       bl = ob->runtime.curve_cache->bev.first;
        if (!bl->nr) return false;
        if (bl->poly > -1) cycl = 1;
 
@@ -573,7 +573,7 @@ static bool where_on_path_deform(Object *ob, float ctime, float vec[4], float di
        if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
 
                if (cycl == 0) {
-                       Path *path = ob->curve_cache->path;
+                       Path *path = ob->runtime.curve_cache->path;
                        float dvec[3];
 
                        if (ctime < 0.0f) {
@@ -610,12 +610,12 @@ static bool calc_curve_deform(Object *par, float co[3],
        short index;
        const bool is_neg_axis = (axis > 2);
 
-       if (par->curve_cache == NULL) {
+       if (par->runtime.curve_cache == NULL) {
                /* Happens with a cyclic dependencies. */
                return false;
        }
 
-       if (par->curve_cache->path == NULL) {
+       if (par->runtime.curve_cache->path == NULL) {
                return false;  /* happens on append, cyclic dependencies and empty curves */
        }
 
@@ -625,7 +625,7 @@ static bool calc_curve_deform(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->curve_cache->path->totdist);
+                       fac = -(co[index] - cd->dmax[index]) / (par->runtime.curve_cache->path->totdist);
        }
        else {
                index = axis;
@@ -633,8 +633,8 @@ static bool calc_curve_deform(Object *par, float co[3],
                        fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]);
                }
                else {
-                       if (LIKELY(par->curve_cache->path->totdist > FLT_EPSILON)) {
-                               fac = +(co[index] - cd->dmin[index]) / (par->curve_cache->path->totdist);
+                       if (LIKELY(par->runtime.curve_cache->path->totdist > FLT_EPSILON)) {
+                               fac = +(co[index] - cd->dmin[index]) / (par->runtime.curve_cache->path->totdist);
                        }
                        else {
                                fac = 0.0f;
@@ -1035,11 +1035,11 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
        int numVerts, editmode = (lt->editlatt != NULL);
        const ModifierEvalContext mectx = {depsgraph, ob, 0};
 
-       if (ob->curve_cache) {
-               BKE_displist_free(&ob->curve_cache->disp);
+       if (ob->runtime.curve_cache) {
+               BKE_displist_free(&ob->runtime.curve_cache->disp);
        }
        else {
-               ob->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for lattice");
+               ob->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for lattice");
        }
 
        for (; md; md = md->next) {
@@ -1071,7 +1071,7 @@ void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, Scene *scene, Objec
                dl->nr = numVerts;
                dl->verts = (float *) vertexCos;
 
-               BLI_addtail(&ob->curve_cache->disp, dl);
+               BLI_addtail(&ob->runtime.curve_cache->disp, dl);
        }
 }
 
@@ -1145,7 +1145,7 @@ BoundBox *BKE_lattice_boundbox_get(Object *ob)
 
 void BKE_lattice_minmax_dl(Object *ob, Lattice *lt, float min[3], float max[3])
 {
-       DispList *dl = ob->curve_cache ? BKE_displist_find(&ob->curve_cache->disp, DL_VERTS) : NULL;
+       DispList *dl = ob->runtime.curve_cache ? BKE_displist_find(&ob->runtime.curve_cache->disp, DL_VERTS) : NULL;
 
        if (!dl) {
                BKE_lattice_minmax(lt, min, max);
index ab8c8695495480ae9d2f7c82fc30645c599e898f..28d75811185f1bd8c3045948a975313400eb71c6 100644 (file)
@@ -926,8 +926,8 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
        /* check indices from mesh */
        if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
                material_data_index_remove_id((ID *)ob->data, actcol - 1);
-               if (ob->curve_cache) {
-                       BKE_displist_free(&ob->curve_cache->disp);
+               if (ob->runtime.curve_cache) {
+                       BKE_displist_free(&ob->runtime.curve_cache->disp);
                }
        }
 
index 2ff69c5ee6d0a12bd9b421a097a3d813ae5595f5..43b7eba2810ad1abdfcd3ff451162ed7b25fb527 100644 (file)
@@ -207,7 +207,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->curve_cache->disp.first;
+       dl = ob->runtime.curve_cache->disp.first;
        while (dl) {
                tot = dl->nr;
                if (tot) do_it = true;
index 738f116310b2eaae08b005f34bb359e2871a4b39..2e2afa6834bc390c6c1c5e265e6500ecc93cd07b 100644 (file)
@@ -217,8 +217,8 @@ int BKE_mesh_nurbs_to_mdata(
 {
        ListBase disp = {NULL, NULL};
 
-       if (ob->curve_cache) {
-               disp = ob->curve_cache->disp;
+       if (ob->runtime.curve_cache) {
+               disp = ob->runtime.curve_cache->disp;
        }
 
        return BKE_mesh_nurbs_displist_to_mdata(
@@ -537,8 +537,8 @@ Mesh *BKE_mesh_new_nomain_from_curve(Object *ob)
 {
        ListBase disp = {NULL, NULL};
 
-       if (ob->curve_cache) {
-               disp = ob->curve_cache->disp;
+       if (ob->runtime.curve_cache) {
+               disp = ob->runtime.curve_cache->disp;
        }
 
        return BKE_mesh_new_nomain_from_curve_displist(ob, &disp);
@@ -650,8 +650,8 @@ void BKE_mesh_from_nurbs(Main *bmain, Object *ob)
        bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0;
        ListBase disp = {NULL, NULL};
 
-       if (ob->curve_cache) {
-               disp = ob->curve_cache->disp;
+       if (ob->runtime.curve_cache) {
+               disp = ob->runtime.curve_cache->disp;
        }
 
        BKE_mesh_from_nurbs_displist(bmain, ob, &disp, use_orco_uv, cu->id.name, false);
@@ -871,11 +871,11 @@ Mesh *BKE_mesh_new_from_object(
                         *
                         * TODO(sergey): Look into more proper solution.
                         */
-                       if (ob->curve_cache != NULL) {
-                               if (tmpobj->curve_cache == NULL) {
-                                       tmpobj->curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
+                       if (ob->runtime.curve_cache != NULL) {
+                               if (tmpobj->runtime.curve_cache == NULL) {
+                                       tmpobj->runtime.curve_cache = MEM_callocN(sizeof(CurveCache), "CurveCache for curve types");
                                }
-                               BKE_displist_copy(&tmpobj->curve_cache->disp, &ob->curve_cache->disp);
+                               BKE_displist_copy(&tmpobj->runtime.curve_cache->disp, &ob->runtime.curve_cache->disp);
                        }
 
                        /* if getting the original caged mesh, delete object modifiers */
@@ -953,8 +953,8 @@ Mesh *BKE_mesh_new_from_object(
                        }
                        else {
                                ListBase disp = {NULL, NULL};
-                               if (ob->curve_cache) {
-                                       disp = ob->curve_cache->disp;
+                               if (ob->runtime.curve_cache) {
+                                       disp = ob->runtime.curve_cache->disp;
                                }
                                BKE_mesh_from_metaball(&disp, tmpmesh);
                        }
index 1d6b23ce7f7d296565ce8374bb27b1ea8dfe7639..21b5bb89f19e6ce407a826a455a03e17fd77cc0a 100644 (file)
@@ -170,15 +170,15 @@ void BKE_object_free_softbody(Object *ob)
 
 void BKE_object_free_curve_cache(Object *ob)
 {
-       if (ob->curve_cache) {
-               BKE_displist_free(&ob->curve_cache->disp);
-               BKE_curve_bevelList_free(&ob->curve_cache->bev);
-               if (ob->curve_cache->path) {
-                       free_path(ob->curve_cache->path);
+       if (ob->runtime.curve_cache) {
+               BKE_displist_free(&ob->runtime.curve_cache->disp);
+               BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
+               if (ob->runtime.curve_cache->path) {
+                       free_path(ob->runtime.curve_cache->path);
                }
-               BKE_nurbList_free(&ob->curve_cache->deformed_nurbs);
-               MEM_freeN(ob->curve_cache);
-               ob->curve_cache = NULL;
+               BKE_nurbList_free(&ob->runtime.curve_cache->deformed_nurbs);
+               MEM_freeN(ob->runtime.curve_cache);
+               ob->runtime.curve_cache = NULL;
        }
 }
 
@@ -460,12 +460,12 @@ void BKE_object_free(Object *ob)
        BLI_freelistN(&ob->lodlevels);
 
        /* Free runtime curves data. */
-       if (ob->curve_cache) {
-               BKE_curve_bevelList_free(&ob->curve_cache->bev);
-               if (ob->curve_cache->path)
-                       free_path(ob->curve_cache->path);
-               MEM_freeN(ob->curve_cache);
-               ob->curve_cache = NULL;
+       if (ob->runtime.curve_cache) {
+               BKE_curve_bevelList_free(&ob->runtime.curve_cache->bev);
+               if (ob->runtime.curve_cache->path)
+                       free_path(ob->runtime.curve_cache->path);
+               MEM_freeN(ob->runtime.curve_cache);
+               ob->runtime.curve_cache = NULL;
        }
 
        BKE_previewimg_free(&ob->preview);
@@ -1154,6 +1154,9 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
 {
        ModifierData *md;
 
+       /* Do not copy runtime data. */
+       BKE_object_runtime_reset(ob_dst);
+
        /* We never handle usercount here for own data. */
        const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
 
@@ -1212,9 +1215,6 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con
 
        copy_object_lod(ob_dst, ob_src, flag_subdata);
 
-       /* Do not copy runtime curve data. */
-       ob_dst->curve_cache = NULL;
-
        /* Do not copy object's preview (mostly due to the fact renderers create temp copy of objects). */
        if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) {  /* XXX TODO temp hack */
                BKE_previewimg_id_copy(&ob_dst->id, &ob_src->id);
@@ -1725,7 +1725,7 @@ static bool ob_parcurve(Depsgraph *depsgraph, Scene *UNUSED(scene), Object *ob,
        }
 #endif
 
-       if (par->curve_cache->path == NULL) {
+       if (par->runtime.curve_cache->path == NULL) {
                return false;
        }
 
@@ -1944,10 +1944,10 @@ static void give_parvert(Object *par, int nr, float vec[3])
                ListBase *nurb;
 
                /* Unless there's some weird depsgraph failure the cache should exist. */
-               BLI_assert(par->curve_cache != NULL);
+               BLI_assert(par->runtime.curve_cache != NULL);
 
-               if (par->curve_cache->deformed_nurbs.first != NULL) {
-                       nurb = &par->curve_cache->deformed_nurbs;
+               if (par->runtime.curve_cache->deformed_nurbs.first != NULL) {
+                       nurb = &par->runtime.curve_cache->deformed_nurbs;
                }
                else {
                        Curve *cu = par->data;
@@ -1958,7 +1958,7 @@ static void give_parvert(Object *par, int nr, float vec[3])
        }
        else if (par->type == OB_LATTICE) {
                Lattice *latt  = par->data;
-               DispList *dl   = par->curve_cache ? BKE_displist_find(&par->curve_cache->disp, DL_VERTS) : NULL;
+               DispList *dl   = par->runtime.curve_cache ? BKE_displist_find(&par->runtime.curve_cache->disp, DL_VERTS) : NULL;
                float (*co)[3] = dl ? (float (*)[3])dl->verts : NULL;
                int tot;
 
@@ -2539,10 +2539,10 @@ void BKE_object_foreach_display_point(
                        func_cb(co, user_data);
                }
        }
-       else if (ob->curve_cache && ob->curve_cache->disp.first) {
+       else if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) {
                DispList *dl;
 
-               for (dl = ob->curve_cache->disp.first; dl; dl = dl->next) {
+               for (dl = ob->runtime.curve_cache->disp.first; dl; dl = dl->next) {
                        const float *v3 = dl->verts;
                        int totvert = dl->nr;
                        int i;
index f226693b989fad4c1bc748d51e481e1474326c9d..816a527d82970bbd06a3ea590b842a65ac916a71 100644 (file)
@@ -5547,9 +5547,6 @@ static void direct_link_object(FileData *fd, Object *ob)
        BKE_object_runtime_reset(ob);
        link_list(fd, &ob->pc_ids);
 
-       /* Runtime curve data  */
-       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);
 
index 20aec0ba5ed4ce51f482a3eab5de95ff4472d51e..b5b339001058314a7bb602cd835e9e9619f7d346 100644 (file)
@@ -732,7 +732,7 @@ static void deg_backup_object_runtime(
         Object *object,
         ObjectRuntimeBackup *object_runtime_backup)
 {
-       /* Store evaluated mesh, and make sure we don't free it. */
+       /* Store evaluated mesh and curve_cache, and make sure we don't free it. */
        Mesh *mesh_eval = object->runtime.mesh_eval;
        object_runtime_backup->runtime = object->runtime;
        BKE_object_runtime_reset(object);
@@ -743,9 +743,6 @@ static void deg_backup_object_runtime(
        if (mesh_eval != NULL && object->data == mesh_eval) {
                object->data = object->runtime.mesh_orig;
        }
-       /* Store curve cache and make sure we don't free it. */
-       object_runtime_backup->curve_cache = object->curve_cache;
-       object->curve_cache = NULL;
        /* Make a backup of base flags. */
        object_runtime_backup->base_flag = object->base_flag;
 }
@@ -783,9 +780,6 @@ static void deg_restore_object_runtime(
                        }
                }
        }
-       if (object_runtime_backup->curve_cache != NULL) {
-               object->curve_cache = object_runtime_backup->curve_cache;
-       }
        object->base_flag = object_runtime_backup->base_flag;
 }
 
index dff863b11bb6329d260214ea52e85292ff61385f..bdfa3211f7ca9235075c040b293e40dc4253d2cc 100644 (file)
@@ -2954,7 +2954,7 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
        BLI_assert(ob->type == OB_CURVE);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache);
+       return DRW_curve_batch_cache_get_wire_edge(cu, ob->runtime.curve_cache);
 }
 
 GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size)
@@ -2962,7 +2962,7 @@ GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob, float normal_size)
        BLI_assert(ob->type == OB_CURVE);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_normal_edge(cu, ob->curve_cache, normal_size);
+       return DRW_curve_batch_cache_get_normal_edge(cu, ob->runtime.curve_cache, normal_size);
 }
 
 GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob)
@@ -2986,7 +2986,7 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
        BLI_assert(ob->type == OB_CURVE);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache);
+       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
 }
 
 /* Return list of batches */
@@ -2996,7 +2996,7 @@ GPUBatch **DRW_cache_curve_surface_shaded_get(
        BLI_assert(ob->type == OB_CURVE);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len);
+       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->runtime.curve_cache, gpumat_array, gpumat_array_len);
 }
 
 /** \} */
@@ -3032,7 +3032,7 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
        BLI_assert(ob->type == OB_FONT);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_wire_edge(cu, ob->curve_cache);
+       return DRW_curve_batch_cache_get_wire_edge(cu, ob->runtime.curve_cache);
 }
 
 GPUBatch *DRW_cache_text_surface_get(Object *ob)
@@ -3042,7 +3042,7 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
        if (cu->editfont && (cu->flag & CU_FAST)) {
                return NULL;
        }
-       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache);
+       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
 }
 
 GPUBatch **DRW_cache_text_surface_shaded_get(
@@ -3053,7 +3053,7 @@ GPUBatch **DRW_cache_text_surface_shaded_get(
        if (cu->editfont && (cu->flag & CU_FAST)) {
                return NULL;
        }
-       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len);
+       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->runtime.curve_cache, gpumat_array, gpumat_array_len);
 }
 
 GPUBatch *DRW_cache_text_cursor_overlay_get(Object *ob)
@@ -3082,7 +3082,7 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
        BLI_assert(ob->type == OB_SURF);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->curve_cache);
+       return DRW_curve_batch_cache_get_triangles_with_normals(cu, ob->runtime.curve_cache);
 }
 
 /* Return list of batches */
@@ -3092,7 +3092,7 @@ GPUBatch **DRW_cache_surf_surface_shaded_get(
        BLI_assert(ob->type == OB_SURF);
 
        struct Curve *cu = ob->data;
-       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->curve_cache, gpumat_array, gpumat_array_len);
+       return DRW_curve_batch_cache_get_surface_shaded(cu, ob->runtime.curve_cache, gpumat_array, gpumat_array_len);
 }
 
 /** \} */
index 375b0ba6bb22e3631616d8166f46b75edbd8ba4d..2172997a714ed45048d0c4ad8d31bec70e33ad67 100644 (file)
@@ -140,7 +140,7 @@ GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(Object *ob)
        MetaBallBatchCache *cache = metaball_batch_cache_get(mb);
 
        if (cache->batch == NULL) {
-               ListBase *lb = &ob->curve_cache->disp;
+               ListBase *lb = &ob->runtime.curve_cache->disp;
                cache->batch = GPU_batch_create_ex(
                        GPU_PRIM_TRIS,
                        DRW_displist_vertbuf_calc_pos_with_normals(lb),
index 9e9785f5e5c20d835e308e7285e9802675416cbe..db906714dd52c512ec6a4459b99e54428638f4d2 100644 (file)
@@ -1663,7 +1663,7 @@ static void DRW_shgroup_forcefield(OBJECT_StorageList *stl, Object *ob, ViewLaye
                        }
                        break;
                case PFIELD_GUIDE:
-                       if (cu && (cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
+                       if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->path && ob->runtime.curve_cache->path->data) {
                                where_on_path(ob, 0.0f, pd->drawvec1, tmp, NULL, NULL, NULL);
                                where_on_path(ob, 1.0f, pd->drawvec2, tmp, NULL, NULL, NULL);
                        }
@@ -1704,7 +1704,7 @@ static void DRW_shgroup_forcefield(OBJECT_StorageList *stl, Object *ob, ViewLaye
                        DRW_shgroup_call_dynamic_add(stl->g_data->field_vortex, color, &pd->drawvec1, ob->obmat);
                        break;
                case PFIELD_GUIDE:
-                       if (cu && (cu->flag & CU_PATH) && ob->curve_cache->path && ob->curve_cache->path->data) {
+                       if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->path && ob->runtime.curve_cache->path->data) {
                                DRW_shgroup_call_dynamic_add(stl->g_data->field_curve_sta, color, &pd->f_strength, ob->obmat);
                                DRW_shgroup_call_dynamic_add(stl->g_data->field_curve_end, color, &pd->f_strength, ob->obmat);
                        }
index 1d7a9ac46c72e5e341020c4b2580750ce46ba757..f7d54e3bc4f63d37b532041e0e1169e14d2c272a 100644 (file)
@@ -6260,12 +6260,12 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
        float min[3], max[3], size[3], loc[3];
        int a;
 
-       if (object->curve_cache == NULL) {
+       if (object->runtime.curve_cache == NULL) {
                BKE_displist_make_curveTypes(depsgraph, scene, object, false);
        }
 
        INIT_MINMAX(min, max);
-       BKE_displist_minmax(&object->curve_cache->disp, min, max);
+       BKE_displist_minmax(&object->runtime.curve_cache->disp, min, max);
 
        mid_v3_v3v3(loc, min, max);
 
index 8c60dd01e89e0724afd26371d3830b231834b1b0..68e84ec3f3b3f1ee84d570e715f1c93d9c264e22 100644 (file)
@@ -1479,7 +1479,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
 
                ob_dst->parent = NULL;
                BKE_constraints_free(&ob_dst->constraints);
-               ob_dst->curve_cache = NULL;
+               ob_dst->runtime.curve_cache = NULL;
                ob_dst->transflag &= ~OB_DUPLI;
 
                copy_m4_m4(ob_dst->obmat, dob->mat);
@@ -1638,7 +1638,7 @@ static const EnumPropertyItem convert_target_items[] = {
 
 static void convert_ensure_curve_cache(Depsgraph *depsgraph, Scene *scene, Object *ob)
 {
-       if (ob->curve_cache == NULL) {
+       if (ob->runtime.curve_cache == NULL) {
                /* Force creation. This is normally not needed but on operator
                 * redo we might end up with an object which isn't evaluated yet.
                 */
@@ -1966,7 +1966,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                                }
 
                                convert_ensure_curve_cache(depsgraph, scene, baseob);
-                               BKE_mesh_from_metaball(&baseob->curve_cache->disp, newob->data);
+                               BKE_mesh_from_metaball(&baseob->runtime.curve_cache->disp, newob->data);
 
                                if (obact->type == OB_MBALL) {
                                        basact = basen;
index 4745a484475d0a10073a7a3ffb31b7dd2129c19a..331b4af077d2a27cdc50894d7396de3ce37b1688 100644 (file)
@@ -716,7 +716,7 @@ bool ED_object_parent_set(ReportList *reports, const bContext *C, Scene *scene,
                                                                if (md) {
                                                                        ((CurveModifierData *)md)->object = par;
                                                                }
-                                                               if (par->curve_cache && par->curve_cache->path == NULL) {
+                                                               if (par->runtime.curve_cache && par->runtime.curve_cache->path == NULL) {
                                                                        DEG_id_tag_update(&par->id, OB_RECALC_DATA);
                                                                }
                                                        }
index 3830e6d279224ca3748fd847c2a08a913e18ccbd..8aa37bb5e16bcb454be1e31bb9dd6dbb71631221 100644 (file)
@@ -127,8 +127,8 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats)
                {
                        int totv = 0, totf = 0, tottri = 0;
 
-                       if (ob->curve_cache && ob->curve_cache->disp.first)
-                               BKE_displist_count(&ob->curve_cache->disp, &totv, &totf, &tottri);
+                       if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first)
+                               BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri);
 
                        totv   *= totob;
                        totf   *= totob;
index eae0cf8e459aecd1ab5403bb7c11a55f3f0758fb..74071e779010275790ed5bd94eb32ea186a29a33 100644 (file)
@@ -380,7 +380,7 @@ void lattice_foreachScreenVert(
        Object *obedit = vc->obedit;
        Lattice *lt = obedit->data;
        BPoint *bp = lt->editlatt->latt->def;
-       DispList *dl = obedit->curve_cache ? BKE_displist_find(&obedit->curve_cache->disp, DL_VERTS) : NULL;
+       DispList *dl = obedit->runtime.curve_cache ? BKE_displist_find(&obedit->runtime.curve_cache->disp, DL_VERTS) : NULL;
        const float *co = dl ? dl->verts : NULL;
        int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw;
 
index edc87c492a6a93a324423d726241be9354adfa77..a8d50543e808772a775c3e1d507c0bea0249ddf8 100644 (file)
@@ -142,6 +142,10 @@ typedef struct Object_Runtime {
         * It has deforemation only modifiers applied on it.
         */
        struct Mesh *mesh_deform_eval;
+
+
+       /* Runtime evaluated curve-specific data, not stored in the file. */
+       struct CurveCache *curve_cache;
 } Object_Runtime;
 
 typedef struct Object {
@@ -280,9 +284,6 @@ typedef struct Object {
        uint64_t lastDataMask;   /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
        uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
 
-       /* Runtime valuated curve-specific data, not stored in the file */
-       struct CurveCache *curve_cache;
-
        ListBase pc_ids;
 
        struct RigidBodyOb *rigidbody_object;           /* settings for Bullet rigid body */
index 5ae0013aab0c49955b44e146e7846f590606bb6f..085f21fe13899d68c58854a4c9261e1742619751 100644 (file)
@@ -456,9 +456,10 @@ static Mesh *arrayModifier_doArray(
        if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
                Curve *cu = amd->curve_ob->data;
                if (cu) {
-                       if (amd->curve_ob->curve_cache && amd->curve_ob->curve_cache->path) {
+                       CurveCache *curve_cache = amd->curve_ob->runtime.curve_cache;
+                       if (curve_cache != NULL && curve_cache->path != NULL) {
                                float scale_fac = mat4_to_scale(amd->curve_ob->obmat);
-                               length = scale_fac * amd->curve_ob->curve_cache->path->totdist;
+                               length = scale_fac * curve_cache->path->totdist;
                        }
                }
        }