[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57958] branches/soc-2013-depsgraph_mt/ source/blender: Wrap runtime curve members into own structure

Sergey Sharybin sergey.vfx at gmail.com
Wed Jul 3 14:32:29 CEST 2013


Revision: 57958
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57958
Author:   nazgul
Date:     2013-07-03 12:32:29 +0000 (Wed, 03 Jul 2013)
Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_curve.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/anim.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/armature.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/cdderivedmesh.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/constraint.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/effect.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/font.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/lattice.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/material.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mball.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/mesh.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/object.c
    branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/object/object_add.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_info/info_stats.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/drawobject.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/space_view3d/view3d_iterators.c
    branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_object_types.h
    branches/soc-2013-depsgraph_mt/source/blender/makesrna/intern/rna_main_api.c
    branches/soc-2013-depsgraph_mt/source/blender/modifiers/intern/MOD_array.c

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_curve.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_curve.h	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_curve.h	2013-07-03 12:32:29 UTC (rev 57958)
@@ -42,7 +42,14 @@
 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) )
 

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_object.h	2013-07-03 12:32:29 UTC (rev 57958)
@@ -60,6 +60,7 @@
 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);

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/anim.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/anim.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/anim.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -509,11 +509,11 @@
 	}
 	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 @@
 	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 @@
 
 	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;

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/armature.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/armature.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/armature.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -1821,11 +1821,11 @@
 		 */
 
 		/* 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 @@
 
 		/* 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

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/cdderivedmesh.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/cdderivedmesh.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -1818,7 +1818,13 @@
 
 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)

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/constraint.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/constraint.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -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 @@
 {
 	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 @@
 		 */
 		
 		/* 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 @@
 		/* 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 @@
 		 */
 		
 		/* 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 @@
 		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 @@
 		 */
 		
 		/* 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);
 	}
 	

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -1419,10 +1419,10 @@
 				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 @@
 	/* 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;

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c	2013-07-03 12:32:17 UTC (rev 57957)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c	2013-07-03 12:32:29 UTC (rev 57958)
@@ -668,10 +668,10 @@
 	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 @@
 	if (!ob || ob->type != OB_MBALL)
 		return;
 
-	BKE_displist_free(&(ob->disp));

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list