[Bf-blender-cvs] [b908fa3] strand_nodes: Always cache the original strand vertex locations during editing.
Lukas Tönne
noreply at git.blender.org
Sun Aug 7 10:39:48 CEST 2016
Commit: b908fa3fdab51f350885d82d73082df6cc56bec7
Author: Lukas Tönne
Date: Tue Aug 2 13:55:36 2016 +0200
Branches: strand_nodes
https://developer.blender.org/rBb908fa3fdab51f350885d82d73082df6cc56bec7
Always cache the original strand vertex locations during editing.
True constraint resolving for length and contacts will need this information.
===================================================================
M source/blender/blenkernel/BKE_editstrands.h
M source/blender/blenkernel/intern/editstrands.c
M source/blender/editors/hair/hair_edit.c
M source/blender/physics/intern/strands.cpp
===================================================================
diff --git a/source/blender/blenkernel/BKE_editstrands.h b/source/blender/blenkernel/BKE_editstrands.h
index b40819d..82258a3 100644
--- a/source/blender/blenkernel/BKE_editstrands.h
+++ b/source/blender/blenkernel/BKE_editstrands.h
@@ -87,6 +87,7 @@ bool BKE_editstrands_get_matrix(struct BMEditStrands *edit, struct BMVert *curve
*/
typedef float (*BMEditStrandsLocations)[3];
BMEditStrandsLocations BKE_editstrands_get_locations(struct BMEditStrands *edit);
+void BKE_editstrands_update_locations(struct BMEditStrands *edit, BMEditStrandsLocations locs);
void BKE_editstrands_free_locations(BMEditStrandsLocations locs);
void BKE_editstrands_get_collision_contacts(struct Scene *scene, struct Object *ob, struct BMEditStrands *edit,
diff --git a/source/blender/blenkernel/intern/editstrands.c b/source/blender/blenkernel/intern/editstrands.c
index c3b70a4..2bdcbac 100644
--- a/source/blender/blenkernel/intern/editstrands.c
+++ b/source/blender/blenkernel/intern/editstrands.c
@@ -207,6 +207,14 @@ BMEditStrandsLocations BKE_editstrands_get_locations(BMEditStrands *edit)
BMesh *bm = edit->base.bm;
BMEditStrandsLocations locs = MEM_mallocN(3*sizeof(float) * bm->totvert, "editstrands locations");
+ BKE_editstrands_update_locations(edit, locs);
+
+ return locs;
+}
+
+void BKE_editstrands_update_locations(struct BMEditStrands *edit, BMEditStrandsLocations locs)
+{
+ BMesh *bm = edit->base.bm;
BMVert *v;
BMIter iter;
int i;
@@ -214,8 +222,6 @@ BMEditStrandsLocations BKE_editstrands_get_locations(BMEditStrands *edit)
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)
diff --git a/source/blender/editors/hair/hair_edit.c b/source/blender/editors/hair/hair_edit.c
index be70a4e..47d2a58 100644
--- a/source/blender/editors/hair/hair_edit.c
+++ b/source/blender/editors/hair/hair_edit.c
@@ -342,14 +342,18 @@ static bool hair_stroke_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
mul_m4_v3(tool_data.imat, tool_data.loc);
mul_mat3_m4_v3(tool_data.imat, tool_data.delta);
+ BMEditStrandsLocations locs = BKE_editstrands_get_locations(edit);
for (step = 0; step < totsteps; ++step) {
bool step_updated = hair_brush_step(&tool_data);
- if (step_updated)
- BKE_editstrands_solve_constraints(scene, ob, edit, NULL);
+ if (step_updated) {
+ BKE_editstrands_solve_constraints(scene, ob, edit, locs);
+ BKE_editstrands_update_locations(edit, locs);
+ }
updated |= step_updated;
}
+ BKE_editstrands_free_locations(locs);
copy_v2_v2(stroke->lastmouse, mouse);
diff --git a/source/blender/physics/intern/strands.cpp b/source/blender/physics/intern/strands.cpp
index 44a92dc..cafe444 100644
--- a/source/blender/physics/intern/strands.cpp
+++ b/source/blender/physics/intern/strands.cpp
@@ -415,6 +415,7 @@ static void strands_solve_inverse_kinematics(Object *ob, BMEditStrands *edit, fl
void BPH_strands_solve_constraints(Scene *scene, Object *ob, BMEditStrands *edit, float (*orig)[3])
{
HairEditSettings *settings = &scene->toolsettings->hair_edit;
+ BLI_assert(orig);
strands_apply_root_locations(edit);
@@ -422,8 +423,7 @@ void BPH_strands_solve_constraints(Scene *scene, Object *ob, BMEditStrands *edit
strands_solve_edge_relaxation(edit);
}
else {
- if (orig)
- strands_solve_inverse_kinematics(ob, edit, orig);
+ strands_solve_inverse_kinematics(ob, edit, orig);
}
More information about the Bf-blender-cvs
mailing list