Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-02-13 12:06:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-02-13 12:06:44 +0400
commit74f268c44238aa8ab8a3e4f781cfb00de360ee70 (patch)
tree84ba96e225f3f9ba5c8a9a0db2a8b83c5b4e8b0d /source/blender/modifiers
parentdb173f6ef87e299568100b5222a4c35947373f96 (diff)
bring array cap ends back, with 2 todo's
* they are not drawn in editmode * weld does't work foe the caps
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 0f25fdbe88b..dd40dc6f59b 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -162,6 +162,29 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis)
return max_co - min_co;
}
+/* Used for start/end cap.
+ *
+ * this function expects all existing vertices to be tagged,
+ * so we can know new verts are not tagged.
+ *
+ * All verts will be tagged on exit.
+ */
+static void bmesh_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4])
+{
+ BMVert *v;
+ BMIter iter;
+
+ DM_to_bmesh_ex(dm, bm);
+
+ /* transform all verts */
+ BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
+ if (!BM_elem_flag_test(v, BM_ELEM_TAG)) {
+ mul_m4_v3(mat, v->co);
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
+ }
+}
+
static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
Scene *scene, Object *ob, DerivedMesh *dm,
int UNUSED(initFlags))
@@ -172,6 +195,8 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
int i, j, indexLen;
/* offset matrix */
float offset[4][4];
+ float final_offset[4][4];
+ float tmp_mat[4][4];
float length = amd->length;
int count = amd->count, maxVerts;
int *indexMap = NULL;
@@ -212,6 +237,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
copy_m4_m4(offset, result_mat);
}
+ /* calculate the offset matrix of the final copy (for merging) */
+ unit_m4(final_offset);
+
+ for(j=0; j < count - 1; j++) {
+ mult_m4_m4m4(tmp_mat, offset, final_offset);
+ copy_m4_m4(final_offset, tmp_mat);
+ }
+
if(amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob) {
Curve *cu = amd->curve_ob->data;
if(cu) {
@@ -338,6 +371,33 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd,
if (j > 0) BMO_op_finish(em->bm, &op);
+ /* BMESH_TODO - cap ends are not welded, even though weld is called after */
+
+ /* start capping */
+ if ((start_cap || end_cap) &&
+
+ /* BMESH_TODO - theres a bug in DM_to_bmesh_ex() when in editmode!
+ * this needs investigation, but for now at least dont crash */
+ ob->mode != OB_MODE_EDIT
+
+ )
+ {
+ BM_mesh_elem_flag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG);
+
+ if (start_cap) {
+ float startoffset[4][4];
+ invert_m4_m4(startoffset, offset);
+ bmesh_merge_dm_transform(em->bm, start_cap, startoffset);
+ }
+
+ if (end_cap) {
+ float endoffset[4][4];
+ mult_m4_m4m4(endoffset, offset, final_offset);
+ bmesh_merge_dm_transform(em->bm, end_cap, endoffset);
+ }
+ }
+ /* done capping */
+
if (amd->flags & MOD_ARR_MERGE)
BMO_op_exec(em->bm, &weldop);