[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60855] branches/vgroup_modifiers/source/ blender/blenkernel/intern/DerivedMesh.c: Fix crash with bmesh.
Bastien Montagne
montagne29 at wanadoo.fr
Sat Oct 19 13:09:50 CEST 2013
Revision: 60855
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60855
Author: mont29
Date: 2013-10-19 11:09:49 +0000 (Sat, 19 Oct 2013)
Log Message:
-----------
Fix crash with bmesh.
I dreamt I could use EDBM just like CDDM... But no. So for now, force creation of a CDDM in edit mode, in case we use loop normals.
Adding support to this in EDBM/EBM will require to add loop normals calc functions to BMesh itself, this will be obvioulsy needed ultimately, but prefer to have a fully working "DM-only" loop normals handling, before diving in BM!
Note: I still do not get the "flat" flag of faces in split normals calc, while "sharp" edge flag is available, don?\226?\128?\153t know why yet.
Modified Paths:
--------------
branches/vgroup_modifiers/source/blender/blenkernel/intern/DerivedMesh.c
Modified: branches/vgroup_modifiers/source/blender/blenkernel/intern/DerivedMesh.c
===================================================================
--- branches/vgroup_modifiers/source/blender/blenkernel/intern/DerivedMesh.c 2013-10-18 23:50:29 UTC (rev 60854)
+++ branches/vgroup_modifiers/source/blender/blenkernel/intern/DerivedMesh.c 2013-10-19 11:09:49 UTC (rev 60855)
@@ -409,6 +409,9 @@
const int numLoops = dm->getNumLoops(dm);
const int numPolys = dm->getNumPolys(dm);
+ /* EditDerivedBMesh has its own way of handling this... */
+ BLI_assert(dm->type != DM_TYPE_EDITBMESH);
+
ldata = dm->getLoopDataLayout(dm);
if (CustomData_has_layer(ldata, CD_NORMAL)) {
lnors = CustomData_get_layer(ldata, CD_NORMAL);
@@ -417,8 +420,6 @@
lnors = CustomData_add_layer(ldata, CD_NORMAL, CD_CALLOC, NULL, numLoops);
}
- /* Vertex normals. */
- DM_ensure_normals(dm);
/* Looks like poly normals are actually not computed/stored in dm, so pdata is of no use for us... */
/* XXX This is very sub-optimal, poly normals are computed here and then again in dm_ensure_display_normals...
* Simplest solution would probably to store them in a temp CD layer?
@@ -434,6 +435,9 @@
BKE_mesh_calc_normals_poly(mverts, numVerts, mloops, mpolys, numLoops, numPolys, pnors, false);
}
+ /* Vertex normals. */
+ DM_ensure_normals(dm);
+
BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops, mpolys, pnors, numPolys,
split_angle);
}
@@ -2042,11 +2046,24 @@
modifiers_clearErrors(ob);
- if (cage_r && cageIndex == -1) {
+ if (cage_r && cageIndex == -1 && !(ob->flag & OB_USE_LOOPNORMALS)) {
*cage_r = getEditDerivedBMesh(em, ob, NULL);
}
- dm = NULL;
+ /* XXX Temp solution!
+ * Until I add loop normals support to bmesh...
+ */
+ if (ob->flag & OB_USE_LOOPNORMALS) {
+ dm = CDDM_from_editbmesh(em, FALSE, FALSE);
+ ASSERT_IS_VALID_DM(dm);
+
+ if (cage_r) {
+ *cage_r = dm;
+ }
+ }
+ else {
+ dm = NULL;
+ }
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
/* copied from mesh_calc_modifiers */
@@ -2254,13 +2271,16 @@
DM_update_statvis_color(scene, ob, *final_r);
}
- if (ob->flag & OB_USE_LOOPNORMALS) {
+ if (((*final_r)->type != DM_TYPE_EDITBMESH) && (ob->flag & OB_USE_LOOPNORMALS)) {
/* Compute loop normals */
DM_calc_loop_normals(*final_r, ob->split_angle);
- if (cage_r && *cage_r && *cage_r != *final_r) {
- DM_calc_loop_normals(*cage_r, ob->split_angle);
- }
}
+ if (cage_r && *cage_r && (*cage_r != *final_r) && ((*cage_r)->type != DM_TYPE_EDITBMESH) &&
+ (ob->flag & OB_USE_LOOPNORMALS))
+ {
+ /* Compute loop normals */
+ DM_calc_loop_normals(*cage_r, ob->split_angle);
+ }
/* --- */
/* BMESH_ONLY, ensure tessface's used for drawing,
@@ -2279,7 +2299,7 @@
}
/* --- */
- /* same as mesh_calc_modifiers (if we use loop normals, vertex and poly ones have already been set). */
+ /* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
if (!(ob->flag & OB_USE_LOOPNORMALS)) {
dm_ensure_display_normals(*final_r);
}
More information about the Bf-blender-cvs
mailing list