Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaul Kedem <shaul_kedem@yahoo.com>2009-01-15 06:05:19 +0300
committerShaul Kedem <shaul_kedem@yahoo.com>2009-01-15 06:05:19 +0300
commit18b1bc88f742fe1686d56dce86d84bead827978f (patch)
tree763724cf7cb6470469b099f7cd5375cc1d5e550b /source/blender/editors
parentba755e3265bd3fcec6006968a5faeb15e799f28d (diff)
edit mesh primitives: ctrl+1 to ctrl+6. monkey does not show and tube,cone and cylinder show with problems
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/mesh/editmesh_add.c231
-rw-r--r--source/blender/editors/mesh/mesh_intern.h6
-rw-r--r--source/blender/editors/mesh/mesh_ops.c32
3 files changed, 261 insertions, 8 deletions
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index 3c3cbc8411a..b1af1221cf3 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -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 @@ signed char monkeyf[250][4]= {
// ------------------------------- 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 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
translateflag(em, 2, vec);
}
break;
- case 11: /* UVsphere */
+ case PRIM_UVSPHERE: /* UVsphere */
/* clear all flags */
eve= em->verts.first;
@@ -1012,7 +1021,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
eve= eve->next;
}
break;
- case 12: /* Icosphere */
+ case PRIM_ICOSPHERE: /* Icosphere */
{
EditVert *eva[12];
EditEdge *eed;
@@ -1061,7 +1070,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
}
}
break;
- case 13: /* Monkey */
+ case PRIM_MONKEY: /* Monkey */
{
//extern int monkeyo, monkeynv, monkeynf;
//extern signed char monkeyf[][4];
@@ -1445,6 +1454,185 @@ void MESH_OT_add_primitive_plane(wmOperatorType *ot)
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 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op)
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 @@ void MESH_OT_add_primitive_grid(wmOperatorType *ot)
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
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index e11b4c38446..6d5bd16c23d 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -95,7 +95,13 @@ void em_setup_viewcontext(struct bContext *C, ViewContext *vc);
/* ******************* 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 */
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index 4557d778337..b052f2ee4b5 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -77,13 +77,21 @@ void ED_operatortypes_mesh(void)
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 @@ void ED_keymap_mesh(wmWindowManager *wm)
/* 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);
+ RNA_boolean_set(circle->ptr,"fill",1);
+ RNA_float_set(circle->ptr,"radius",2);
+
+ cylinder = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cylinder", THREEKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_int_set(cylinder->ptr,"vertices",32);
+ RNA_float_set(cylinder->ptr,"radius",2);
+ RNA_float_set(cylinder->ptr,"depth",3);
+
+ tube = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_tube", FOURKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_int_set(tube->ptr,"vertices",32);
+ RNA_float_set(tube->ptr,"radius",2);
+ RNA_float_set(tube->ptr,"depth",3);
+
+ cone = WM_keymap_add_item(keymap, "MESH_OT_add_primitive_cone", FIVEKEY, KM_PRESS, KM_CTRL, 0);
+ RNA_int_set(cone->ptr,"vertices",32);
+ RNA_float_set(cone->ptr,"radius",2);
+ RNA_float_set(cone->ptr,"depth",-3);
+ RNA_float_set(cone->ptr,"cap end",0);
+
WM_keymap_add_item(keymap, "MESH_OT_add_primitive_grid", NINEKEY, KM_PRESS, KM_CTRL, 0);
+
+ WM_keymap_add_item(keymap, "MESH_OT_add_primitive_monkey", SIXKEY, KM_PRESS, KM_CTRL, 0);
}