Page MenuHome

patch.txt

patch.txt

? patch.txt
Index: editmesh_add.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editmesh_add.c,v
retrieving revision 1.50
diff -u -r1.50 editmesh_add.c
--- editmesh_add.c 26 Nov 2005 13:09:25 -0000 1.50
+++ editmesh_add.c 17 Apr 2006 20:38:25 -0000
@@ -701,7 +701,38 @@
Transform();
}
+/* check whether an object to add mesh to exists, if not, create one
+* returns 1 if new object created, else 0 */
+int confirm_objectExists( Mesh **me, float *mat[][3] )
+{
+ int newob = 0;
+
+ /* deselectall */
+ EM_clear_flag_all(SELECT);
+
+ /* if no obedit: new object and enter editmode */
+ if(G.obedit==NULL) {
+ /* add_object actually returns an object ! :-)
+ But it also stores the added object struct in
+ G.scene->basact->object (BASACT->object) */
+ add_object_draw(OB_MESH);
+
+ G.obedit= BASACT->object;
+
+ where_is_object(G.obedit);
+
+ make_editMesh();
+ setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
+ newob= 1;
+ }
+ *me = G.obedit->data;
+
+ /* imat and centre and size */
+ Mat3CpyMat4(*mat, G.obedit->obmat);
+
+ return newob;
+}
void add_primitiveMesh(int type)
{
@@ -727,48 +758,9 @@
G.f &= ~(G_VERTEXPAINT+G_FACESELECT+G_TEXTUREPAINT);
setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
}
-
- /* if no obedit: new object and enter editmode */
- if(G.obedit==NULL) {
- /* add_object actually returns an object ! :-)
- But it also stores the added object struct in
- G.scene->basact->object (BASACT->object) */
-
- add_object_draw(OB_MESH);
-
- G.obedit= BASACT->object;
-
- where_is_object(G.obedit);
-
- make_editMesh();
- setcursor_space(SPACE_VIEW3D, CURSOR_EDIT);
- newob= 1;
- }
- me= G.obedit->data;
-
- /* deselectall */
- EM_clear_flag_all(SELECT);
totoud= tot; /* store, and restore when cube/plane */
- /* imat and centre and size */
- Mat3CpyMat4(mat, G.obedit->obmat);
-
- curs= give_cursor();
- VECCOPY(cent, curs);
- cent[0]-= G.obedit->obmat[3][0];
- cent[1]-= G.obedit->obmat[3][1];
- cent[2]-= G.obedit->obmat[3][2];
-
- if(type!= 31) {
- Mat3CpyMat4(imat, G.vd->viewmat);
- Mat3MulVecfl(imat, cent);
- Mat3MulMat3(cmat, imat, mat);
- Mat3Inv(imat,cmat);
- } else {
- Mat3Inv(imat, mat);
- }
-
/* ext==extrudeflag, tot==amount of vertices in basis */
switch(type) {
@@ -776,6 +768,7 @@
tot= 4;
ext= 0;
fill= 1;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Plane");
if(newob) rename_id((ID *)me, "Plane");
undostr="Add Plane";
@@ -784,6 +777,7 @@
tot= 4;
ext= 1;
fill= 1;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Cube");
if(newob) rename_id((ID *)me, "Cube");
undostr="Add Cube";
@@ -792,6 +786,7 @@
if(button(&tot,3,100,"Vertices:")==0) return;
ext= 0;
fill= 0;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Circle");
if(newob) rename_id((ID *)me, "Circle");
undostr="Add Circle";
@@ -800,6 +795,7 @@
if(button(&tot,3,100,"Vertices:")==0) return;
ext= 1;
fill= 1;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Cylinder");
if(newob) rename_id((ID *)me, "Cylinder");
undostr="Add Cylinder";
@@ -808,6 +804,7 @@
if(button(&tot,3,100,"Vertices:")==0) return;
ext= 1;
fill= 0;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Tube");
if(newob) rename_id((ID *)me, "Tube");
undostr="Add Tube";
@@ -816,6 +813,7 @@
if(button(&tot,3,100,"Vertices:")==0) return;
ext= 0;
fill= 1;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Cone");
if(newob) rename_id((ID *)me, "Cone");
undostr="Add Cone";
@@ -823,6 +821,7 @@
case 10: /* grid */
if(button(&tot,2,100,"X res:")==0) return;
if(button(&seg,2,100,"Y res:")==0) return;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Grid");
if(newob) rename_id((ID *)me, "Grid");
undostr="Add Grid";
@@ -830,23 +829,45 @@
case 11: /* UVsphere */
if(button(&seg,3,100,"Segments:")==0) return;
if(button(&tot,3,100,"Rings:")==0) return;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Sphere");
if(newob) rename_id((ID *)me, "Sphere");
undostr="Add UV Sphere";
break;
case 12: /* Icosphere */
if(button(&subdiv,1,5,"Subdivision:")==0) return;
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Sphere");
if(newob) rename_id((ID *)me, "Sphere");
undostr="Add Ico Sphere";
break;
case 13: /* Monkey */
+ newob = confirm_objectExists( &me, &mat );
if(newob) rename_id((ID *)G.obedit, "Suzanne");
if(newob) rename_id((ID *)me, "Suzanne");
undostr="Add Monkey";
break;
+ default:
+ newob = confirm_objectExists( &me, &mat );
+ break;
}
+ curs= give_cursor();
+ VECCOPY(cent, curs);
+ cent[0]-= G.obedit->obmat[3][0];
+ cent[1]-= G.obedit->obmat[3][1];
+ cent[2]-= G.obedit->obmat[3][2];
+
+ /* 31 is a prime number */
+ if(type!= 31) {
+ Mat3CpyMat4(imat, G.vd->viewmat);
+ Mat3MulVecfl(imat, cent);
+ Mat3MulMat3(cmat, imat, mat);
+ Mat3Inv(imat,cmat);
+ } else {
+ Mat3Inv(imat, mat);
+ }
+
dia= sqrt(2.0)*G.vd->grid;
d= -G.vd->grid;
phid= 2*M_PI/tot;

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2a/70/13a511d00a5d8489f42e6862223d

Event Timeline