[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11471] branches/2-44-stable/blender: updated python Mesh API doc and bugfix.
Campbell Barton
cbarton at metavr.com
Thu Aug 2 22:36:57 CEST 2007
Revision: 11471
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11471
Author: campbellbarton
Date: 2007-08-02 22:36:57 +0200 (Thu, 02 Aug 2007)
Log Message:
-----------
updated python Mesh API doc and bugfix.
[#6815] script error and segfault in conjunction with multires, fake AO and vertex paint mode
https://projects.blender.org/tracker/?func=detail&aid=6815&group_id=9&atid=125
While looking at this problem I found that doing this in blender (as well as python) crashed.
- cube, add multires, vkey, fkay, paint (crash)
Whenver a color layer is added, multires needs to be updated.
if (me->mr) multires_load_cols(me);
There is still a problem with multires+vcol+uv's
removing a UV layer, will remove all color layers other then the active one. (before it removed all of them)
Modified Paths:
--------------
branches/2-44-stable/blender/release/scripts/vertexpaint_selfshadow_ao.py
branches/2-44-stable/blender/source/blender/include/multires.h
branches/2-44-stable/blender/source/blender/python/api2_2x/Mesh.c
branches/2-44-stable/blender/source/blender/python/api2_2x/doc/Mesh.py
branches/2-44-stable/blender/source/blender/src/buttons_editing.c
branches/2-44-stable/blender/source/blender/src/vpaint.c
Modified: branches/2-44-stable/blender/release/scripts/vertexpaint_selfshadow_ao.py
===================================================================
--- branches/2-44-stable/blender/release/scripts/vertexpaint_selfshadow_ao.py 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/release/scripts/vertexpaint_selfshadow_ao.py 2007-08-02 20:36:57 UTC (rev 11471)
@@ -39,6 +39,7 @@
# --------------------------------------------------------------------------
from Blender import Scene, Draw, sys, Window, Mathutils, Mesh
+import bpy
import BPyMesh
@@ -135,10 +136,10 @@
Window.WaitCursor(0)
def main():
- scn= Scene.GetCurrent()
- ob= scn.getActiveObject()
+ sce= bpy.data.scenes.active
+ ob= sce.objects.active
- if not ob or ob.getType() != 'Mesh':
+ if not ob or ob.type != 'Mesh':
Draw.PupMenu('Error, no active mesh object, aborting.')
return
@@ -174,8 +175,8 @@
PREF_SHADOW_ONLY= PREF_SHADOW_ONLY.val
PREF_SEL_ONLY= PREF_SEL_ONLY.val
- if not me.faceUV:
- me.faceUV= 1
+ if not me.vertexColors:
+ me.vertexColors= 1
t= sys.time()
vertexFakeAO(me, PREF_BLUR_ITERATIONS, PREF_BLUR_RADIUS, PREF_MIN_EDLEN, PREF_CLAMP_CONCAVE, PREF_CLAMP_CONVEX, PREF_SHADOW_ONLY, PREF_SEL_ONLY)
Modified: branches/2-44-stable/blender/source/blender/include/multires.h
===================================================================
--- branches/2-44-stable/blender/source/blender/include/multires.h 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/source/blender/include/multires.h 2007-08-02 20:36:57 UTC (rev 11471)
@@ -63,6 +63,9 @@
void multires_edge_level_update(void *ob, void *me);
int multires_modifier_warning();
+/* after adding or removing vcolor layers, run this */
+void multires_load_cols(Mesh *me);
+
/* multires-firstlevel.c */
/* Generic */
void multires_update_customdata(struct MultiresLevel *lvl1, struct CustomData *src,
Modified: branches/2-44-stable/blender/source/blender/python/api2_2x/Mesh.c
===================================================================
--- branches/2-44-stable/blender/source/blender/python/api2_2x/Mesh.c 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/source/blender/python/api2_2x/Mesh.c 2007-08-02 20:36:57 UTC (rev 11471)
@@ -6445,6 +6445,9 @@
CustomData_add_layer(data, type, CD_DEFAULT,
NULL, me->totface);
mesh_update_customdata_pointers(me);
+ if (type==CD_MCOL && me->mr)
+ multires_load_cols(me);
+
Py_RETURN_NONE;
}
@@ -6493,6 +6496,9 @@
}
}
+ if (type==CD_MCOL && me->mr)
+ multires_load_cols(me);
+
Py_RETURN_NONE;
}
@@ -7376,7 +7382,9 @@
} else if( !mesh->mcol ) {
/* TODO: mesh_create_shadedColors */
mesh->mcol = CustomData_add_layer( &mesh->fdata, CD_MCOL,
- CD_DEFAULT, NULL, mesh->totface );
+ CD_DEFAULT, NULL, mesh->totface );
+
+ if (mesh->mr) multires_load_cols(mesh);
}
return 0;
case MESH_HASVERTUV:
Modified: branches/2-44-stable/blender/source/blender/python/api2_2x/doc/Mesh.py
===================================================================
--- branches/2-44-stable/blender/source/blender/python/api2_2x/doc/Mesh.py 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/source/blender/python/api2_2x/doc/Mesh.py 2007-08-02 20:36:57 UTC (rev 11471)
@@ -17,6 +17,7 @@
Example::
from Blender import *
+ import bpy
editmode = Window.EditMode() # are we in edit mode? If so ...
if editmode: Window.EditMode(0) # leave edit mode before getting the mesh
@@ -25,7 +26,7 @@
coords=[ [-1,-1,-1], [1,-1,-1], [1,1,-1], [-1,1,-1], [0,0,1] ]
faces= [ [3,2,1,0], [0,1,4], [1,2,4], [2,3,4], [3,0,4] ]
- me = Mesh.New('myMesh') # create a new mesh
+ me = bpy.data.meshes.new('myMesh') # create a new mesh
me.verts.extend(coords) # add vertices to mesh
me.faces.extend(faces) # add faces to the mesh (also adds edges)
@@ -35,7 +36,7 @@
me.faces[1].col[1].g = 255
me.faces[1].col[2].b = 255
- scn = Scene.GetCurrent() # link object to current scene
+ scn = bpy.data.scenes.active # link object to current scene
ob = scn.objects.new(me, 'myObj')
if editmode: Window.EditMode(1) # optional, just being nice
@@ -518,7 +519,7 @@
me= ob.getData(mesh=1) # thin wrapper doesn't copy mesh data like nmesh
me.vertexColors= True # Enable face, vertex colors
for f in me.faces:
- for i, v in enumerate(f.v):
+ for i, v in enumerate(f):
no= v.no
col= f.col[i]
col.r= int((no.x+1)*128)
@@ -740,19 +741,9 @@
@type hide: boolean
@ivar subDivLevels: The [display, rendering] subdivision levels in [1, 6].
@type subDivLevels: list of 2 ints
-
- @ivar faceUV: The mesh contains UV-mapped textured faces. Enabling faceUV
- does not initialize the face colors like the Blender UI does; this must
- be done in the script. B{Note}: if faceUV is set, L{vertexColors} cannot
- be set. Furthermore, if vertexColors is already set when faceUV is set,
- vertexColors is cleared. This is because the vertex color information
- is stored with UV faces, so enabling faceUV implies enabling vertexColors.
- In addition, faceUV cannot be set when the mesh has no faces defined
- (this is the same behavior as the UI). Attempting to do so will throw
- a RuntimeError exception.
+ @ivar faceUV: The mesh contains UV-mapped textured faces.
@type faceUV: bool
- @ivar vertexColors: The mesh contains vertex colors. See L{faceUV} for the
- use of vertex colors when UV-mapped texture faces are enabled.
+ @ivar vertexColors: The mesh contains vertex colors. Set True to add vertex colors.
@type vertexColors: bool
@ivar vertexUV: The mesh contains "sticky" per-vertex UV coordinates.
@type vertexUV: bool
Modified: branches/2-44-stable/blender/source/blender/src/buttons_editing.c
===================================================================
--- branches/2-44-stable/blender/source/blender/src/buttons_editing.c 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/source/blender/src/buttons_editing.c 2007-08-02 20:36:57 UTC (rev 11471)
@@ -4149,6 +4149,8 @@
if(!mcol)
shadeMeshMCol(ob, me);
}
+
+ if (me->mr) multires_load_cols(me);
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
BIF_undo_push("New Vertex Color");
Modified: branches/2-44-stable/blender/source/blender/src/vpaint.c
===================================================================
--- branches/2-44-stable/blender/source/blender/src/vpaint.c 2007-08-02 09:45:25 UTC (rev 11470)
+++ branches/2-44-stable/blender/source/blender/src/vpaint.c 2007-08-02 20:36:57 UTC (rev 11471)
@@ -250,7 +250,9 @@
shadeMeshMCol(ob, me);
else
memset(me->mcol, 255, 4*sizeof(MCol)*me->totface);
-
+
+ if (me->mr) multires_load_cols(me);
+
DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
allqueue(REDRAWBUTSEDIT, 0);
More information about the Bf-blender-cvs
mailing list