[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42126] trunk/blender/source/blender: Fix #29369: bpy.data.curves.new(name= "test" , type = 'SURFACE') does not create a surface

Sergey Sharybin sergey.vfx at gmail.com
Thu Nov 24 15:30:41 CET 2011


Revision: 42126
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42126
Author:   nazgul
Date:     2011-11-24 14:30:37 +0000 (Thu, 24 Nov 2011)
Log Message:
-----------
Fix #29369: bpy.data.curves.new(name= "test" , type = 'SURFACE') does not create a surface

This issue it totally related on issue with changing object datablock.
For curves it used to guess object type from curve datablock based on
count of control points in V direction.
This quess fails in case when SurfCircle datablock is trying to be reused
by another surface object or as another sample empty surface databouck used
to be treated as curve.

Store type in Curve when creating new Curve datablock which is used in
this object type quessing function.

Note: Previously saved files wouldn't change behavior at all.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/curve.c
    trunk/blender/source/blender/editors/object/object_add.c
    trunk/blender/source/blender/makesdna/DNA_curve_types.h

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2011-11-24 13:51:31 UTC (rev 42125)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2011-11-24 14:30:37 UTC (rev 42126)
@@ -169,6 +169,7 @@
 	cu->texflag= CU_AUTOSPACE;
 	cu->smallcaps_scale= 0.75f;
 	cu->twist_mode= CU_TWIST_MINIMUM;	// XXX: this one seems to be the best one in most cases, at least for curve deform...
+	cu->type= type;
 	
 	cu->bb= unit_boundbox();
 	
@@ -303,16 +304,23 @@
 short curve_type(Curve *cu)
 {
 	Nurb *nu;
+	int type= cu->type;
+
 	if(cu->vfont) {
 		return OB_FONT;
 	}
-	for (nu= cu->nurb.first; nu; nu= nu->next) {
-		if(nu->pntsv>1) {
-			return OB_SURF;
+
+	if(!cu->type) {
+		type= OB_CURVE;
+
+		for (nu= cu->nurb.first; nu; nu= nu->next) {
+			if(nu->pntsv>1) {
+				type= OB_SURF;
+			}
 		}
 	}
-	
-	return OB_CURVE;
+
+	return type;
 }
 
 void update_curve_dimension(Curve *cu)

Modified: trunk/blender/source/blender/editors/object/object_add.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_add.c	2011-11-24 13:51:31 UTC (rev 42125)
+++ trunk/blender/source/blender/editors/object/object_add.c	2011-11-24 14:30:37 UTC (rev 42126)
@@ -1366,6 +1366,7 @@
 				makeDispListCurveTypes(scene, newob, 0);
 
 			newob->type= OB_CURVE;
+			cu->type= OB_CURVE;
 
 			if(cu->vfont) {
 				cu->vfont->id.us--;

Modified: trunk/blender/source/blender/makesdna/DNA_curve_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_curve_types.h	2011-11-24 13:51:31 UTC (rev 42125)
+++ trunk/blender/source/blender/makesdna/DNA_curve_types.h	2011-11-24 14:30:37 UTC (rev 42126)
@@ -186,7 +186,9 @@
 	float size[3];
 	float rot[3];
 
-	short texflag, pad1; /* keep a short because of give_obdata_texspace() */
+	short type;	/* creation-time type of curve datablock */
+
+	short texflag; /* keep a short because of give_obdata_texspace() */
 	short drawflag, twist_mode;
 	float twist_smooth, smallcaps_scale;
 




More information about the Bf-blender-cvs mailing list