[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29631] trunk/blender/source/blender/ editors: Fix #22642: NURBS surfaces doesnt display

Sergey Sharybin g.ulairi at gmail.com
Tue Jun 22 23:11:13 CEST 2010


Revision: 29631
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29631
Author:   nazgul
Date:     2010-06-22 23:11:13 +0200 (Tue, 22 Jun 2010)

Log Message:
-----------
Fix #22642: NURBS surfaces doesnt display
Fix #22587: Invisible Nurbs Suface

There was a small bug with determinating if new object should be created
and for surfeces new OB_CURVE object had been created (instead of OB_SURF).

Removed unused function and enum, which were used by nurbs surface
create old oprator

Modified Paths:
--------------
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/object/object_add.c

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2010-06-22 21:09:50 UTC (rev 29630)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2010-06-22 21:11:13 UTC (rev 29631)
@@ -5256,54 +5256,62 @@
 	return nu;
 }
 
-static int curve_prim_add(bContext *C, wmOperator *op, int type){
+static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) {
 	
 	Object *obedit= CTX_data_edit_object(C);
 	ListBase *editnurb;
 	Nurb *nu;
-	int newob= 0;//, type= RNA_enum_get(op->ptr, "type");
+	int newob= 0;
 	int enter_editmode;
 	unsigned int layer;
 	float loc[3], rot[3];
 	float mat[4][4];
-	
-	//object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
+
 	if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
 		return OPERATOR_CANCELLED;
 
-	
-	if(obedit==NULL || obedit->type!=OB_CURVE) {
-		Curve *cu;
-		obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
-		newob = 1;
+	if (!isSurf) { /* adding curve */
+		if(obedit==NULL || obedit->type!=OB_CURVE) {
+			Curve *cu;
+			obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
+			newob = 1;
 
-		cu= (Curve*)obedit->data;
-		cu->flag |= CU_DEFORM_FILL;
-		if(type & CU_PRIM_PATH)
-			cu->flag |= CU_PATH|CU_3D;
+			cu= (Curve*)obedit->data;
+			cu->flag |= CU_DEFORM_FILL;
+			if(type & CU_PRIM_PATH)
+				cu->flag |= CU_PATH|CU_3D;
+		} else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
+	} else { /* adding surface */
+		if(obedit==NULL || obedit->type!=OB_SURF) {
+			obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer);
+			newob = 1;
+		} else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
 	}
-	else if(obedit==NULL || obedit->type!=OB_SURF) {
-		obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer);
-		newob = 1;
-	}
-	else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
-	
-	
+
 	ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
-	
+
 	nu= add_nurbs_primitive(C, mat, type, newob);
 	editnurb= curve_get_editcurve(obedit);
 	BLI_addtail(editnurb, nu);
-	
+
 	/* userdef */
 	if (newob && !enter_editmode) {
 		ED_object_exit_editmode(C, EM_FREEDATA);
 	}
-	
+
 	WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
-	
+
 	return OPERATOR_FINISHED;
 }
+
+static int curve_prim_add(bContext *C, wmOperator *op, int type) {
+	return curvesurf_prim_add(C, op, type, 0);
+}
+
+static int surf_prim_add(bContext *C, wmOperator *op, int type) {
+	return curvesurf_prim_add(C, op, type, 1);
+}
+
 /* ******************** Curves ******************* */
 
 static int add_primitive_bezier_exec(bContext *C, wmOperator *op)
@@ -5424,7 +5432,7 @@
 /* **************** NURBS surfaces ********************** */
 static int add_primitive_nurbs_surface_curve_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot)
@@ -5447,7 +5455,7 @@
 
 static int add_primitive_nurbs_surface_circle_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot)
@@ -5470,7 +5478,7 @@
 
 static int add_primitive_nurbs_surface_surface_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot)
@@ -5493,7 +5501,7 @@
 
 static int add_primitive_nurbs_surface_tube_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_tube_add(wmOperatorType *ot)
@@ -5516,7 +5524,7 @@
 
 static int add_primitive_nurbs_surface_sphere_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot)
@@ -5539,7 +5547,7 @@
 
 static int add_primitive_nurbs_surface_donut_exec(bContext *C, wmOperator *op)
 {
-	return curve_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS);
+	return surf_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS);
 }
 
 void SURFACE_OT_primitive_nurbs_surface_donut_add(wmOperatorType *ot)

Modified: trunk/blender/source/blender/editors/object/object_add.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_add.c	2010-06-22 21:09:50 UTC (rev 29630)
+++ trunk/blender/source/blender/editors/object/object_add.c	2010-06-22 21:11:13 UTC (rev 29631)
@@ -490,74 +490,6 @@
 
 /* ***************** add primitives *************** */
 
-static EnumPropertyItem prop_surface_types[]= {
-	{CU_PRIM_CURVE|CU_NURBS, "NURBS_CURVE", ICON_SURFACE_NCURVE, "NURBS Curve", ""},
-	{CU_PRIM_CIRCLE|CU_NURBS, "NURBS_CIRCLE", ICON_SURFACE_NCIRCLE, "NURBS Circle", ""},
-	{CU_PRIM_PATCH|CU_NURBS, "NURBS_SURFACE", ICON_SURFACE_NSURFACE, "NURBS Surface", ""},
-	{CU_PRIM_TUBE|CU_NURBS, "NURBS_TUBE", ICON_SURFACE_NTUBE, "NURBS Tube", ""},
-	{CU_PRIM_SPHERE|CU_NURBS, "NURBS_SPHERE", ICON_SURFACE_NSPHERE, "NURBS Sphere", ""},
-	{CU_PRIM_DONUT|CU_NURBS, "NURBS_DONUT", ICON_SURFACE_NDONUT, "NURBS Donut", ""},
-	{0, NULL, 0, NULL, NULL}
-};
-
-static int object_add_surface_exec(bContext *C, wmOperator *op)
-{
-	Object *obedit= CTX_data_edit_object(C);
-	ListBase *editnurb;
-	Nurb *nu;
-	int newob= 0;
-	int enter_editmode;
-	unsigned int layer;
-	float loc[3], rot[3];
-	float mat[4][4];
-	
-	object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called
-
-	if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer))
-		return OPERATOR_CANCELLED;
-	
-	if(obedit==NULL || obedit->type!=OB_SURF) {
-		obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer);
-		newob = 1;
-	}
-	else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);
-	
-	ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
-	
-	nu= add_nurbs_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob);
-	editnurb= curve_get_editcurve(obedit);
-	BLI_addtail(editnurb, nu);
-	
-	/* userdef */
-	if (newob && !enter_editmode) {
-		ED_object_exit_editmode(C, EM_FREEDATA);
-	}
-	
-	WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
-	
-	return OPERATOR_FINISHED;
-}
-
-void OBJECT_OT_surface_add(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name= "Add Surface";
-	ot->description = "Add a surface object to the scene";
-	ot->idname= "OBJECT_OT_surface_add";
-	
-	/* api callbacks */
-	ot->invoke= WM_menu_invoke;
-	ot->exec= object_add_surface_exec;
-	
-	ot->poll= ED_operator_scene_editable;
-	
-	/* flags */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-	
-	ot->prop= RNA_def_enum(ot->srna, "type", prop_surface_types, 0, "Primitive", "");
-	ED_object_add_generic_props(ot, TRUE);
-}
-
 static EnumPropertyItem prop_metaball_types[]= {
 	{MB_BALL, "MBALL_BALL", ICON_META_BALL, "Meta Ball", ""},
 	{MB_TUBE, "MBALL_TUBE", ICON_META_TUBE, "Meta Tube", ""},





More information about the Bf-blender-cvs mailing list