[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45050] trunk/blender: bmesh docs:
Campbell Barton
ideasman42 at gmail.com
Wed Mar 21 06:33:46 CET 2012
Revision: 45050
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45050
Author: campbellbarton
Date: 2012-03-21 05:33:37 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
bmesh docs:
- add examples for custom-data access
- group BMesh types logically in docs
- added missing docstrings
needed to add grouping functionality to sphinx for this.
Modified Paths:
--------------
trunk/blender/doc/python_api/rst/include__bmesh.rst
trunk/blender/doc/python_api/sphinx_doc_gen.py
trunk/blender/source/blender/blenkernel/intern/bvhutils.c
trunk/blender/source/blender/makesrna/intern/rna_scene.c
trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c
trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.h
trunk/blender/source/blender/python/bmesh/bmesh_py_types_meshdata.c
trunk/blender/source/creator/CMakeLists.txt
Modified: trunk/blender/doc/python_api/rst/include__bmesh.rst
===================================================================
--- trunk/blender/doc/python_api/rst/include__bmesh.rst 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/doc/python_api/rst/include__bmesh.rst 2012-03-21 05:33:37 UTC (rev 45050)
@@ -30,12 +30,21 @@
*Campbell Barton, 13, March 2012*
-.. todo::
+.. warning::
+ TODO Items Are
+
* add access to BMesh **walkers**
* add a way to re-tessellate an editmode bmesh.
+ * add deform vert custom-data access.
+Example Script
+--------------
+
+.. literalinclude:: ../../../release/scripts/templates/bmesh_simple.py
+
+
Stand-Alone Module
^^^^^^^^^^^^^^^^^^
@@ -66,6 +75,35 @@
further access.
+CustomData Access
+-----------------
+
+BMesh has a unified way to access mesh attributes such as UV's vertex colors, shape keys, edge crease etc.
+
+This works by having a **layers** property on bmesh data sequences to access the custom data layers which can then be
+used to access the actual data on each vert/edge/face/loop.
+
+Here are some examples ...
+
+.. code-block:: python
+
+ uv_lay = bm.loops.layers.uv.active
+
+ for face in bm.faces:
+ for loop in f.loops:
+ uv = loop[uv_lay]
+ print("Loop UV: %f, %f" % (uv.x, uv.y))
+
+
+.. code-block:: python
+
+ shape_lay = bm.verts.layers.shape["Key.001"]
+
+ for vert in bm.verts:
+ shape = vert[shape_lay]
+ print("Vert Shape: %f, %f, %f" % (shape.x, shape.y, shape.z))
+
+
Keeping a Correct State
-----------------------
@@ -92,11 +130,5 @@
flush the selection after performing a series of edits. this validates the selection state.
-Example Script
---------------
-
-.. literalinclude:: ../../../release/scripts/templates/bmesh_simple.py
-
-
Module Functions
----------------
Modified: trunk/blender/doc/python_api/sphinx_doc_gen.py
===================================================================
--- trunk/blender/doc/python_api/sphinx_doc_gen.py 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py 2012-03-21 05:33:37 UTC (rev 45050)
@@ -312,6 +312,36 @@
"UserPreferencesSystem": {"language", }
}
+MODULE_GROUPING = {
+ "bmesh.types": (
+ ("Base Mesh Type", '-'),
+ "BMesh",
+ ("Mesh Elements", '-'),
+ "BMVert",
+ "BMEdge",
+ "BMFace",
+ "BMLoop",
+ ("Sequence Accessors", '-'),
+ "BMElemSeq",
+ "BMVertSeq",
+ "BMEdgeSeq",
+ "BMFaceSeq",
+ "BMLoopSeq",
+ "BMIter",
+ ("Selection History", '-'),
+ "BMEditSelSeq",
+ "BMEditSelIter",
+ ("Custom-Data Layer Access", '-'),
+ "BMLayerAccessVert",
+ "BMLayerAccessEdge",
+ "BMLayerAccessFace",
+ "BMLayerAccessLoop",
+ "BMLayerCollection",
+ "BMLayerItem",
+ ("Custom-Data Layer Types", '-'),
+ "BMLoopUV"
+ )
+ }
# --------------------configure compile time options----------------------------
@@ -656,6 +686,29 @@
if module_all:
module_dir = module_all
+ # TODO - currently only used for classes
+ # grouping support
+ module_grouping = MODULE_GROUPING.get(module_name)
+ def module_grouping_index(name):
+ if module_grouping is not None:
+ try:
+ return module_grouping.index(name)
+ except ValueError:
+ pass
+ return -1
+
+ def module_grouping_heading(name):
+ if module_grouping is not None:
+ i = module_grouping_index(name) - 1
+ if i >= 0 and type(module_grouping[i]) == tuple:
+ return module_grouping[i]
+ return None, None
+
+ def module_grouping_sort_key(name):
+ return module_grouping_index(name)
+ # done grouping support
+
+
file = open(filepath, "w", encoding="utf-8")
fw = file.write
@@ -805,8 +858,17 @@
fw("\n")
'''
+ if module_grouping is not None:
+ classes.sort(key=lambda pair: module_grouping_sort_key(pair[0]))
+
# write collected classes now
for (type_name, value) in classes:
+
+ if module_grouping is not None:
+ heading, heading_char = module_grouping_heading(type_name)
+ if heading:
+ fw(title_string(heading, heading_char))
+
# May need to be its own function
fw(".. class:: %s\n\n" % type_name)
if value.__doc__:
@@ -1412,7 +1474,7 @@
fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n")
- app_modules = [
+ app_modules = (
"bpy.context", # note: not actually a module
"bpy.data", # note: not actually a module
"bpy.ops",
@@ -1425,8 +1487,9 @@
"bpy.app.handlers",
# C modules
- "bpy.props"
- ]
+ "bpy.props",
+ )
+
for mod in app_modules:
if mod not in EXCLUDE_MODULES:
fw(" %s\n\n" % mod)
@@ -1435,14 +1498,15 @@
fw(".. toctree::\n")
fw(" :maxdepth: 1\n\n")
- standalone_modules = [
+ standalone_modules = (
# mathutils
"mathutils", "mathutils.geometry", "mathutils.noise",
# misc
"bgl", "blf", "gpu", "aud", "bpy_extras",
# bmesh
- "bmesh", "bmesh.types", "bmesh.utils"
- ]
+ "bmesh", "bmesh.types", "bmesh.utils",
+ )
+
for mod in standalone_modules:
if mod not in EXCLUDE_MODULES:
fw(" %s\n\n" % mod)
Modified: trunk/blender/source/blender/blenkernel/intern/bvhutils.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/bvhutils.c 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/source/blender/blenkernel/intern/bvhutils.c 2012-03-21 05:33:37 UTC (rev 45050)
@@ -523,7 +523,7 @@
int i;
int numFaces= mesh->getNumTessFaces(mesh);
- /* BMESH spesific check that we have tessfaces,
+ /* BMESH specific check that we have tessfaces,
* we _could_ tessellate here but rather not - campbell
*
* this assert checks we have tessfaces,
Modified: trunk/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene.c 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene.c 2012-03-21 05:33:37 UTC (rev 45050)
@@ -2785,7 +2785,7 @@
RNA_def_property_ui_text(prop, "Preview", "When rendering animations, save JPG preview images in same directory");
RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
- /* format spesific */
+ /* format specific */
#ifdef WITH_OPENEXR
/* OpenEXR */
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types.c 2012-03-21 05:33:37 UTC (rev 45050)
@@ -180,7 +180,7 @@
}
}
-/* type spesific get/sets
+/* type specific get/sets
* ---------------------- */
Modified: trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c
===================================================================
--- trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c 2012-03-21 04:43:17 UTC (rev 45049)
+++ trunk/blender/source/blender/python/bmesh/bmesh_py_types_customdata.c 2012-03-21 05:33:37 UTC (rev 45050)
@@ -72,6 +72,39 @@
/* getseters
* ========= */
+/* used for many different types */
+
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__float_doc,
+"Generic float custom-data layer.\n\ntype: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__int_doc,
+"Generic int custom-data layer.\n\ntype: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__string_doc,
+"Generic string custom-data layer (exposed as bytes, 255 max length).\n\ntype: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__deform_doc,
+"Vertex deform weight :class:`BMDeformVert` (TODO).\n\ntype: :class:`BMLayerCollection`" // TYPE DOESN'T EXIST YET
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__shape_doc,
+"Vertex shapekey absolute location (as a 3D Vector).\n\n:type: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__bevel_weight_doc,
+"Bevel weight float in [0 - 1].\n\n:type: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__crease_doc,
+"Edge crease for subsurf - float in [0 - 1].\n\n:type: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__tex_doc,
+"Accessor for :class:`BMTexPoly` layer (TODO).\n\ntype: :class:`BMLayerCollection`" // TYPE DOESN'T EXIST YET
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__uv_doc,
+"Accessor for :class:`BMLoopUV` UV (as a 2D Vector).\n\ntype: :class:`BMLayerCollection`"
+);
+PyDoc_STRVAR(bpy_bmlayeraccess_collection__color_doc,
+"Accessor for vertex color layer.\n\ntype: :class:`BMLayerCollection`"
+);
+
static PyObject *bpy_bmlayeraccess_collection_get(BPy_BMLayerAccess *self, void *flag)
{
const int type = (int)GET_INT_FROM_POINTER(flag);
@@ -81,6 +114,10 @@
return BPy_BMLayerCollection_CreatePyObject(self->bm, self->htype, type);
}
+
+PyDoc_STRVAR(bpy_bmlayercollection_active_doc,
+"This meshes vert sequence (read-only).\n\n:type: :class:`BMVertSeq`"
+);
static PyObject *bpy_bmlayercollection_active_get(BPy_BMLayerItem *self, void *UNUSED(flag))
{
CustomData *data;
@@ -99,6 +136,9 @@
}
}
+PyDoc_STRVAR(bpy_bmlayercollection_name_doc,
+"The layers unique name (read-only).\n\n:type: string"
+);
static PyObject *bpy_bmlayeritem_name_get(BPy_BMLayerItem *self, void *UNUSED(flag))
{
CustomDataLayer *layer;
@@ -110,46 +150,46 @@
}
static PyGetSetDef bpy_bmlayeraccess_vert_getseters[] = {
- {(char *)"deform", (getter)bpy_bmlayeraccess_collection_get, (setter)NULL, (char *)NULL, (void *)CD_MDEFORMVERT},
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list