Revision: 18512
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18512
Author:   shul
Date:     2009-01-15 04:05:19 +0100 (Thu, 15 Jan 2009)

Log Message:
-----------
edit mesh primitives: ctrl+1 to ctrl+6. monkey does not show and tube,cone and 
cylinder show with problems

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/mesh/editmesh_add.c
    branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h
    branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c

Modified: branches/blender2.5/blender/source/blender/editors/mesh/editmesh_add.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/editmesh_add.c      
2009-01-15 02:36:24 UTC (rev 18511)
+++ branches/blender2.5/blender/source/blender/editors/mesh/editmesh_add.c      
2009-01-15 03:05:19 UTC (rev 18512)
@@ -44,6 +44,10 @@
 #include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
 
+#include "RNA_types.h"
+#include "RNA_define.h"
+#include "RNA_access.h"
+
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h"
 #include "BLI_editVert.h"
@@ -906,10 +910,15 @@
        // ------------------------------- end copied code
 
 
-#define PRIM_PLANE     0
-#define PRIM_CUBE      1
-#define PRIM_CIRCLE    4
-#define PRIM_GRID      10
+#define PRIM_PLANE             0
+#define PRIM_CUBE              1
+#define PRIM_CIRCLE            4
+#define PRIM_CYLINDER  5
+#define PRIM_CONE              7
+#define PRIM_GRID              10
+#define PRIM_UVSPHERE  11
+#define PRIM_ICOSPHERE         12
+#define PRIM_MONKEY            13
 
 static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int 
seg,
                int subdiv, float dia, float depth, int ext, int fill)
@@ -966,7 +975,7 @@
                        translateflag(em, 2, vec);
                }
                break;
-       case 11: /*  UVsphere */
+       case PRIM_UVSPHERE: /*  UVsphere */
                
                /* clear all flags */
                eve= em->verts.first;
@@ -1012,7 +1021,7 @@
                        eve= eve->next;
                }
                break;
-       case 12: /* Icosphere */
+       case PRIM_ICOSPHERE: /* Icosphere */
                {
                        EditVert *eva[12];
                        EditEdge *eed;
@@ -1061,7 +1070,7 @@
                        }
                }
                break;
-       case 13: /* Monkey */
+       case PRIM_MONKEY: /* Monkey */
                {
                        //extern int monkeyo, monkeynv, monkeynf;
                        //extern signed char monkeyf[][4];
@@ -1445,6 +1454,185 @@
        ot->poll= ED_operator_editmesh;
 }
 
+static int add_primitive_cube_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       /* plane (diameter of 1.41 makes it unit size) */
+       dia*= sqrt(2.0f);
+       
+       make_prim(obedit, PRIM_CUBE, mat, 4, 0, 0, dia, 1.0f, 1, 1);
+       
+       ED_undo_push(C, "Add Cube");    // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_cube(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Cube";
+       ot->idname= "MESH_OT_add_primitive_cube";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_cube_exec;
+       ot->poll= ED_operator_editmesh;
+}
+
+static int add_primitive_circle_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       dia = RNA_float_get(op->ptr,"radius");
+       
+       make_prim(obedit, PRIM_CIRCLE, mat, RNA_int_get(op->ptr,"vertices"), 0, 
0, dia, 0.0f, 0, RNA_boolean_get(op->ptr, "fill"));
+       
+       ED_undo_push(C, "Add Circle");  // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_circle(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Circle";
+       ot->idname= "MESH_OT_add_primitive_circle";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_circle_exec;
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+
+       RNA_def_property(ot->srna, "vertices", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "radius", PROP_FLOAT, PROP_NONE);
+       RNA_def_property(ot->srna, "fill", PROP_BOOLEAN, PROP_NONE);
+}
+
+static int add_primitive_cylinder_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       dia = RNA_float_get(op->ptr,"radius");
+       
+       // XXX cylinder turns out a bit wacky.. play with the cursor to get 
even more interesting stuff
+       make_prim(obedit, PRIM_CYLINDER, mat, 
RNA_int_get(op->ptr,"vertices"),32, 2, dia, RNA_float_get(op->ptr,"depth"), 1, 
1);
+       
+       ED_undo_push(C, "Add Cylinder");        // Note this will become 
depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_cylinder(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Cylinder";
+       ot->idname= "MESH_OT_add_primitive_cylinder";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_cylinder_exec;
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+
+       RNA_def_property(ot->srna, "vertices", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "radius", PROP_FLOAT, PROP_NONE);
+       RNA_def_property(ot->srna, "depth", PROP_FLOAT, PROP_NONE);
+}
+
+static int add_primitive_tube_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       dia = RNA_float_get(op->ptr,"radius");
+       
+       make_prim(obedit, PRIM_CYLINDER, mat, RNA_int_get(op->ptr,"vertices"), 
32, 2, dia, RNA_float_get(op->ptr,"depth")/2, 1, 0);
+       
+       ED_undo_push(C, "Add Tube");    // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_tube(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Tube";
+       ot->idname= "MESH_OT_add_primitive_tube";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_tube_exec;
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+
+       RNA_def_property(ot->srna, "vertices", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "radius", PROP_FLOAT, PROP_NONE);
+       RNA_def_property(ot->srna, "depth", PROP_FLOAT, PROP_NONE);
+}
+
+static int add_primitive_cone_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       dia = RNA_float_get(op->ptr,"radius");
+       
+       make_prim(obedit, PRIM_CONE, mat, RNA_int_get(op->ptr,"vertices"), 32, 
2, dia, RNA_float_get(op->ptr,"depth")/2, 1, RNA_int_get(op->ptr,"cap end"));
+       
+       ED_undo_push(C, "Add Cone");    // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_cone(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Cone";
+       ot->idname= "MESH_OT_add_primitive_cone";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_cone_exec;
+       ot->poll= ED_operator_editmesh;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
+       
+       /* props */
+
+       RNA_def_property(ot->srna, "vertices", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "radius", PROP_FLOAT, PROP_NONE);
+       RNA_def_property(ot->srna, "depth", PROP_FLOAT, PROP_NONE);
+       RNA_def_property(ot->srna, "cap end",PROP_INT, PROP_NONE);
+}
+
 static int add_primitive_grid_exec(bContext *C, wmOperator *op)
 {
        Object *obedit= CTX_data_edit_object(C);
@@ -1457,7 +1645,7 @@
        
        make_prim(obedit, PRIM_GRID, mat, 10, 10, 0, dia, 0.0f, 0, 1);
        
-       ED_undo_push(C, "Add Plane");   // Note this will become depricated 
+       ED_undo_push(C, "Add Grid");    // Note this will become depricated 
        WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
        
        return OPERATOR_FINISHED;       
@@ -1473,3 +1661,30 @@
        ot->exec= add_primitive_grid_exec;
        ot->poll= ED_operator_editmesh;
 }
+
+// XXX No monkey ?!
+static int add_primitive_monkey_exec(bContext *C, wmOperator *op)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       float dia, mat[4][4];
+       
+       dia= new_primitive_matrix(C, mat);
+       
+       make_prim(obedit, PRIM_MONKEY, mat, 32, 32, 2, dia, 0.0f, 0, 0);
+       
+       ED_undo_push(C, "Add Monkey");  // Note this will become depricated 
+       WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
+       
+       return OPERATOR_FINISHED;       
+}
+
+void MESH_OT_add_primitive_monkey(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Add Monkey";
+       ot->idname= "MESH_OT_add_monkey";
+       
+       /* api callbacks */
+       ot->exec= add_primitive_monkey_exec;
+       ot->poll= ED_operator_editmesh;
+}
\ No newline at end of file

Modified: branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h       
2009-01-15 02:36:24 UTC (rev 18511)
+++ branches/blender2.5/blender/source/blender/editors/mesh/mesh_intern.h       
2009-01-15 03:05:19 UTC (rev 18512)
@@ -95,7 +95,13 @@
 
 /* ******************* editmesh_add.c */
 void MESH_OT_add_primitive_plane(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_cube(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_circle(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_cylinder(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_tube(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_cone(struct wmOperatorType *ot);
 void MESH_OT_add_primitive_grid(struct wmOperatorType *ot);
+void MESH_OT_add_primitive_monkey(struct wmOperatorType *ot);
 
 
 /* ******************* editmesh_lib.c */

Modified: branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-01-15 02:36:24 UTC (rev 18511)
+++ branches/blender2.5/blender/source/blender/editors/mesh/mesh_ops.c  
2009-01-15 03:05:19 UTC (rev 18512)
@@ -77,13 +77,21 @@
        WM_operatortype_append(MESH_OT_select_linked_flat_faces);
        WM_operatortype_append(MESH_OT_select_sharp_edges);
        WM_operatortype_append(MESH_OT_add_primitive_plane);
+       WM_operatortype_append(MESH_OT_add_primitive_cube);
+       WM_operatortype_append(MESH_OT_add_primitive_circle);
+       WM_operatortype_append(MESH_OT_add_primitive_cylinder);
+       WM_operatortype_append(MESH_OT_add_primitive_tube);
+       WM_operatortype_append(MESH_OT_add_primitive_cone);
        WM_operatortype_append(MESH_OT_add_primitive_grid);
+       WM_operatortype_append(MESH_OT_add_primitive_monkey);
 
 }
 
 /* note mesh keymap also for other space? */
 void ED_keymap_mesh(wmWindowManager *wm)
 {
+       wmKeymapItem *circle,*cylinder,*tube, *cone;
+       
        ListBase *keymap= WM_keymap_listbase(wm, "EditMesh", 0, 0);
        
        /* selecting */
@@ -108,7 +116,31 @@
        
        /* add */
        WM_keymap_add_item(keymap, "MESH_OT_add_primitive_plane", ZEROKEY, 
KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cube", ONEKEY, 
KM_PRESS, KM_CTRL, 0);
+       circle = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_circle", 
TWOKEY, KM_PRESS, KM_CTRL, 0);
+       RNA_int_set(circle->ptr,"vertices",32);

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to