[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14821] branches/apricot/source/blender: make smooth work with mirror option
Campbell Barton
ideasman42 at gmail.com
Mon May 12 23:41:00 CEST 2008
Revision: 14821
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14821
Author: campbellbarton
Date: 2008-05-12 23:41:00 +0200 (Mon, 12 May 2008)
Log Message:
-----------
make smooth work with mirror option
Modified Paths:
--------------
branches/apricot/source/blender/python/BPY_interface.c
branches/apricot/source/blender/src/editmesh_mods.c
Modified: branches/apricot/source/blender/python/BPY_interface.c
===================================================================
--- branches/apricot/source/blender/python/BPY_interface.c 2008-05-12 21:19:24 UTC (rev 14820)
+++ branches/apricot/source/blender/python/BPY_interface.c 2008-05-12 21:41:00 UTC (rev 14821)
@@ -787,10 +787,10 @@
PyObject *py_dict, *py_res, *pyarg;
Text *text = NULL;
BPy_constant *info;
- int len;
+
+
+
- FILE *fp = NULL;
-
PyGILState_STATE gilstate = PyGILState_Ensure();
if (!BLI_exists(script->scriptname)) {
@@ -834,12 +834,8 @@
Py_INCREF( Py_None );
pyarg = Py_None;
} else {
- if (BLI_exists(script->scriptname)) {
- fp = fopen( script->scriptname, "rb" );
- }
-
- if( !fp ) {
- printf( "Error loading script: couldn't open file %s\n", script->scriptname );
+ if (!BLI_exists(script->scriptname)) {
+ printf( "Script does not exit %s\n", script->scriptname );
free_libblock( &G.main->script, script );
PyGILState_Release(gilstate);
return 0;
@@ -884,47 +880,10 @@
if (text) {
py_res = RunPython( text, py_dict );
} else {
- /* Previously we used PyRun_File to run directly the code on a FILE
- * object, but as written in the Python/C API Ref Manual, chapter 2,
- * 'FILE structs for different C libraries can be different and
- * incompatible'.
- * So now we load the script file data to a buffer */
- char *buffer=NULL, *buffer_ofs=NULL, *b_to, *b_from;
-
- fseek( fp, 0L, SEEK_END );
- len = ftell( fp );
- fseek( fp, 0L, SEEK_SET );
-
- buffer = buffer_ofs = MEM_mallocN( len + 2, "pyfilebuf" ); /* len+2 to add '\n\0' */
- len = fread( buffer, 1, len, fp );
-
- buffer[len] = '\n'; /* fix syntax error in files w/o eol */
- buffer[len + 1] = '\0';
-
-
- /* fast clean-up of dos cr/lf line endings, remove convert '\r\n's to '\n' */
- if (*buffer_ofs == '\r' && *(buffer_ofs+1) == '\n') {
- buffer_ofs++;
- }
- b_from = b_to = buffer_ofs;
-
- while(*b_from != '\0') {
- if (*b_from == '\r' && *( b_from+1 ) == '\n') {
- b_from++;
- }
- if (b_from != b_to) {
- *b_to = *b_from;
- }
- b_to++;
- b_from++;
- }
- *b_to = '\0';
- /* done cleaning the string */
-
- fclose( fp );
-
- py_res = PyRun_String( buffer_ofs, Py_file_input, py_dict, py_dict );
- MEM_freeN( buffer );
+ char pystring[sizeof(script->scriptname) + 14];
+ pystring[0] = '\0';
+ sprintf(pystring, "execfile('%s')", script->scriptname);
+ py_res = PyRun_String( pystring, Py_file_input, py_dict, py_dict );
}
if( !py_res ) { /* Failed execution of the script */
Modified: branches/apricot/source/blender/src/editmesh_mods.c
===================================================================
--- branches/apricot/source/blender/src/editmesh_mods.c 2008-05-12 21:19:24 UTC (rev 14820)
+++ branches/apricot/source/blender/src/editmesh_mods.c 2008-05-12 21:41:00 UTC (rev 14821)
@@ -4150,7 +4150,7 @@
void vertexsmooth(void)
{
EditMesh *em = G.editMesh;
- EditVert *eve;
+ EditVert *eve, *eve_mir = NULL;
EditEdge *eed;
float *adror, *adr, fac;
float fvec[3];
@@ -4233,13 +4233,19 @@
while(eve) {
if(eve->f & SELECT) {
if(eve->f1) {
+
+ if (G.scene->toolsettings->editbutflag & B_MESH_X_MIRROR) {
+ eve_mir= editmesh_get_x_mirror_vert(G.obedit, eve->co);
+ }
+
adr = eve->tmp.p;
fac= 0.5/(float)eve->f1;
eve->co[0]= 0.5*eve->co[0]+fac*adr[0];
eve->co[1]= 0.5*eve->co[1]+fac*adr[1];
eve->co[2]= 0.5*eve->co[2]+fac*adr[2];
-
+
+
/* clip if needed by mirror modifier */
if (eve->f2) {
if (eve->f2 & 1) {
@@ -4252,6 +4258,13 @@
eve->co[2]= 0.0f;
}
}
+
+ if (eve_mir) {
+ eve_mir->co[0]=-eve->co[0];
+ eve_mir->co[1]= eve->co[1];
+ eve_mir->co[2]= eve->co[2];
+ }
+
}
eve->tmp.p= NULL;
}
More information about the Bf-blender-cvs
mailing list