[Bf-blender-cvs] [07221e9] strand_editmode: Merge branch 'master' into strand_editmode
Lukas Tönne
noreply at git.blender.org
Sat Apr 16 18:11:08 CEST 2016
Commit: 07221e980b8b6899ccb0d145210c699b4fca175c
Author: Lukas Tönne
Date: Sat Apr 16 18:10:37 2016 +0200
Branches: strand_editmode
https://developer.blender.org/rB07221e980b8b6899ccb0d145210c699b4fca175c
Merge branch 'master' into strand_editmode
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/space_view3d.py
index ac8f149,cbcdb86..a71a2f1
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@@ -143,10 -156,12 +158,12 @@@ class VIEW3D_MT_editor_menus(Menu)
layout.menu("VIEW3D_MT_select_paint_mask")
elif mesh.use_paint_mask_vertex and mode_string == 'PAINT_WEIGHT':
layout.menu("VIEW3D_MT_select_paint_mask_vertex")
- elif mode_string != 'SCULPT':
+ elif mode_string not in {'SCULPT'}:
layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
- if mode_string == 'OBJECT':
+ if gp_edit:
+ pass
+ elif mode_string == 'OBJECT':
layout.menu("INFO_MT_add", text="Add")
elif mode_string == 'EDIT_MESH':
layout.menu("INFO_MT_mesh_add", text="Add")
diff --cc source/blender/blenkernel/intern/customdata.c
index 2d3c44b,a12d543..97017b1
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@@ -1311,11 -1323,8 +1324,10 @@@ static const LayerTypeInfo LAYERTYPEINF
{sizeof(short[4][3]), "", 0, NULL, NULL, NULL, NULL, layerSwap_flnor, NULL},
/* 41: CD_CUSTOMLOOPNORMAL */
{sizeof(short[2]), "vec2s", 1, NULL, NULL, NULL, NULL, NULL, NULL},
+ /* 42: CD_MESH_SAMPLE */
+ {sizeof(MeshSample), "MeshSample", 1, NULL, NULL, NULL, NULL, NULL, NULL},
};
- /* note, numbers are from trunk and need updating for bmesh */
static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
/* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
@@@ -1364,20 -1373,16 +1376,27 @@@ const CustomDataMask CD_MASK_BMESH
CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
CD_MASK_CUSTOMLOOPNORMAL;
- const CustomDataMask CD_MASK_FACECORNERS = /* XXX Not used anywhere! */
- CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
- CD_MASK_MLOOPCOL | CD_MASK_NORMAL | CD_MASK_MLOOPTANGENT;
+ /**
+ * cover values copied by #BKE_mesh_loops_to_tessdata
+ */
+ const CustomDataMask CD_MASK_FACECORNERS =
+ CD_MASK_MTFACE | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
+ CD_MASK_MCOL | CD_MASK_MLOOPCOL |
+ CD_MASK_PREVIEW_MCOL | CD_MASK_PREVIEW_MLOOPCOL |
+ CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP |
+ CD_MASK_TESSLOOPNORMAL | CD_MASK_NORMAL |
+ CD_MASK_TANGENT | CD_MASK_MLOOPTANGENT;
+const CustomDataMask CD_MASK_STRANDS =
+ CD_MASK_MVERT | CD_MASK_MEDGE |
+ CD_MASK_MDEFORMVERT | CD_MASK_MCOL |
+ CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
+ CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE |
+ CD_MASK_MSURFACE_SAMPLE;
+const CustomDataMask CD_MASK_STRANDS_BMESH =
+ CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
+ CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
+ CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE |
+ CD_MASK_MSURFACE_SAMPLE;
const CustomDataMask CD_MASK_EVERYTHING =
CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_NORMAL /* | CD_MASK_POLYINDEX */ | CD_MASK_PROP_FLT |
diff --cc source/blender/blenkernel/intern/editstrands.c
index 642eee3,0000000..3e03bf9
mode 100644,000000..100644
--- a/source/blender/blenkernel/intern/editstrands.c
+++ b/source/blender/blenkernel/intern/editstrands.c
@@@ -1,204 -1,0 +1,204 @@@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/editstrands.c
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_math.h"
+#include "BLI_mempool.h"
+
+#include "DNA_customdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
+
+#include "BKE_bvhutils.h"
+#include "BKE_customdata.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+#include "BKE_effect.h"
+#include "BKE_mesh_sample.h"
+#include "BKE_particle.h"
+
+#include "BPH_strands.h"
+
+#include "intern/bmesh_strands_conv.h"
+
+BMEditStrands *BKE_editstrands_create(BMesh *bm, DerivedMesh *root_dm)
+{
+ BMEditStrands *es = MEM_callocN(sizeof(BMEditStrands), __func__);
+
+ es->bm = bm;
+ es->root_dm = CDDM_copy(root_dm);
+
+ return es;
+}
+
+BMEditStrands *BKE_editstrands_copy(BMEditStrands *es)
+{
+ BMEditStrands *es_copy = MEM_callocN(sizeof(BMEditStrands), __func__);
+ *es_copy = *es;
+
+ es_copy->bm = BM_mesh_copy(es->bm);
+ es_copy->root_dm = CDDM_copy(es->root_dm);
+
+ return es_copy;
+}
+
+/**
+ * \brief Return the BMEditStrands for a given object
+ */
+BMEditStrands *BKE_editstrands_from_object(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys) {
+ return psys->hairedit;
+ }
+ return NULL;
+}
+
+void BKE_editstrands_update_linked_customdata(BMEditStrands *es)
+{
+ BMesh *bm = es->bm;
+
+ /* this is done for BMEditMesh, but should never exist for strands */
+ BLI_assert(!CustomData_has_layer(&bm->pdata, CD_MTEXPOLY));
+}
+
+/*does not free the BMEditStrands struct itself*/
+void BKE_editstrands_free(BMEditStrands *es)
+{
+ if (es->bm)
+ BM_mesh_free(es->bm);
+ if (es->root_dm)
+ es->root_dm->release(es->root_dm);
+}
+
+/* === constraints === */
+
+BMEditStrandsLocations BKE_editstrands_get_locations(BMEditStrands *edit)
+{
+ BMesh *bm = edit->bm;
+ BMEditStrandsLocations locs = MEM_mallocN(3*sizeof(float) * bm->totvert, "editstrands locations");
+
+ BMVert *v;
+ BMIter iter;
+ int i;
+
+ BM_ITER_MESH_INDEX(v, &iter, bm, BM_VERTS_OF_MESH, i) {
+ copy_v3_v3(locs[i], v->co);
+ }
+
+ return locs;
+}
+
+void BKE_editstrands_free_locations(BMEditStrandsLocations locs)
+{
+ MEM_freeN(locs);
+}
+
+void BKE_editstrands_solve_constraints(Object *ob, BMEditStrands *es, BMEditStrandsLocations orig)
+{
+ BKE_editstrands_ensure(es);
+
+ BPH_strands_solve_constraints(ob, es, orig);
+}
+
+static void editstrands_calc_segment_lengths(BMesh *bm)
+{
+ BMVert *root, *v, *vprev;
+ BMIter iter, iter_strand;
+ int k;
+
+ BM_ITER_STRANDS(root, &iter, bm, BM_STRANDS_OF_MESH) {
+ BM_ITER_STRANDS_ELEM_INDEX(v, &iter_strand, root, BM_VERTS_OF_STRAND, k) {
+ if (k > 0) {
+ float length = len_v3v3(v->co, vprev->co);
+ BM_elem_float_data_named_set(&bm->vdata, v, CD_PROP_FLT, CD_HAIR_SEGMENT_LENGTH, length);
+ }
+ vprev = v;
+ }
+ }
+}
+
+void BKE_editstrands_ensure(BMEditStrands *es)
+{
+ BM_strands_cd_flag_ensure(es->bm, 0);
+
+ if (es->flag & BM_STRANDS_DIRTY_SEGLEN) {
+ editstrands_calc_segment_lengths(es->bm);
+
+ es->flag &= ~BM_STRANDS_DIRTY_SEGLEN;
+ }
+}
+
+
+/* === particle conversion === */
+
+BMesh *BKE_particles_to_bmesh(Object *ob, ParticleSystem *psys)
+{
+ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_PSYS(psys);
+ BMesh *bm;
+
+ bm = BM_mesh_create(&allocsize);
+
- if (psmd && psmd->dm) {
- DM_ensure_tessface(psmd->dm);
++ if (psmd && psmd->dm_final) {
++ DM_ensure_tessface(psmd->dm_final);
+
- BM_strands_bm_from_psys(bm, ob, psys, psmd->dm, true, /*psys->shapenr*/ -1);
++ BM_strands_bm_from_psys(bm, ob, psys, psmd->dm_final, true, /*psys->shapenr*/ -1);
+
+ editstrands_calc_segment_lengths(bm);
+ }
+
+ return bm;
+}
+
+void BKE_particles_from_bmesh(Object *ob, ParticleSystem *psys)
+{
+ ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ BMesh *bm = psys->hairedit ? psys->hairedit->bm : NULL;
+
+ if (bm) {
- if (psmd && psmd->dm) {
++ if (psmd && psmd->dm_final) {
+ BVHTreeFromMesh bvhtree = {NULL};
+
- DM_ensure_tessface(psmd->dm);
++ DM_ensure_tessface(psmd->dm_final);
+
- bvhtree_from_mesh_faces(&bvhtree, psmd->dm, 0.0, 2, 6);
++ bvhtree_from_mesh_faces(&bvhtree, psmd->dm_final, 0.0, 2, 6);
+
- BM_strands_bm_to_psys(bm, ob, psys, psmd->dm, &bvhtree);
++ BM_strands_bm_to_psys(bm, ob, psys, psmd->dm_final, &bvhtree);
+
+ free_bvhtree_from_mesh(&bvhtree);
+ }
+ }
+}
diff --cc source/blender/blenkernel/intern/particle.c
index 7e8bd5a,0987004..fa26e86
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@@ -1526,13 -1580,8 +1586,13 @@@ static int psys_map_index_on_dm(Derived
return 1;
}
+int psys_get_index_on_dm(ParticleSystem *psys, DerivedMesh *dm, ParticleData *pa, int *mapindex, float mapfw[4])
+{
+ return psys_map_index_on_dm(dm, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, mapindex, mapfw);
+}
+
/* interprets particle data to get a point on a mesh in object space */
- void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache,
+ void psys_particle_on_dm(DerivedMesh *dm_final, int from, int index, int index_dmcache,
const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3],
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list