[Bf-blender-cvs] [5ac471a0215] sculpt-dev: Sculpt Array: Initial code for path and path points
aousdfh
noreply at git.blender.org
Thu Jul 15 21:12:25 CEST 2021
Commit: 5ac471a02155a8cdbd0ee46237ebb451be5e7557
Author: aousdfh
Date: Tue Jul 6 01:06:15 2021 +0200
Branches: sculpt-dev
https://developer.blender.org/rB5ac471a02155a8cdbd0ee46237ebb451be5e7557
Sculpt Array: Initial code for path and path points
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/editors/sculpt_paint/sculpt_array.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 321d04557f3..7a14d080572 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -456,10 +456,25 @@ typedef struct SculptArrayCopy {
float origin[3];
} SculptArrayCopy;
+typedef struct ScultpArrayPathPoint {
+ float length;
+ float co[3];
+ float direction[3];
+} ScultpArrayPathPoint;
+
typedef struct SculptArray {
float (*orco)[3];
SculptArrayCopy *copies[PAINT_SYMM_AREAS];
int num_copies;
+
+ struct {
+ ScultpArrayPathPoint * points;
+ int tot_points;
+ int capacity;
+ float total_length;
+ } path;
+
+
} SculptArray;
typedef struct SculptFakeNeighbors {
diff --git a/source/blender/editors/sculpt_paint/sculpt_array.c b/source/blender/editors/sculpt_paint/sculpt_array.c
index e7c2a19f0e4..6aabc8f05a0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_array.c
+++ b/source/blender/editors/sculpt_paint/sculpt_array.c
@@ -325,7 +325,6 @@ static void do_array_deform_task_cb_ex(void *__restrict userdata,
}
}
-
static void sculpt_array_deform(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) {
SculptSession *ss = ob->sculpt;
/* Threaded loop over nodes. */
@@ -356,6 +355,32 @@ static void sculpt_array_ensure_original_coordinates(Object *ob, SculptArray *ar
}
}
+
+static void sculpt_array_stroke_sample_add(Object *ob, SculptArray *array) {
+ SculptSession *ss = ob->sculpt;
+
+ if (!array->path.points) {
+ array->path.points = MEM_malloc_arrayN(9999, sizeof(ScultpArrayPathPoint), "Array Path");
+ }
+
+ const int current_point_index = array->path.tot_points;
+ const int prev_point_index = current_point_index - 1;
+
+ ScultpArrayPathPoint *path_point = &array->path.points[current_point_index];
+ add_v3_v3v3(path_point->co, ss->cache->true_initial_location, ss->cache->grab_delta);
+ if (current_point_index == 0) {
+ /* First point of the path. */
+ path_point->length = 0.0f;
+ }
+ else {
+ ScultpArrayPathPoint *prev_path_point = &array->path.points[prev_point_index];
+ sub_v3_v3v3(prev_path_point->direction, path_point->co, prev_path_point->co);
+ path_point->length += normalize_v3(prev_path_point->direction);
+ }
+
+ array->path.tot_points++;
+}
+
void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
{
SculptSession *ss = ob->sculpt;
@@ -374,21 +399,7 @@ void SCULPT_do_array_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
return;
}
- /* TODO: delete this. */
- sculpt_array_ensure_original_coordinates(ob, ss->cache->array);
- /*
- Mesh *sculpt_mesh = BKE_object_get_original_mesh(ob);
- const int totvert = SCULPT_vertex_count_get(ss);
-
- if (!ss->cache->array_orco) {
- ss->cache->array_orco = MEM_calloc_arrayN(sculpt_mesh->totvert, sizeof(float) * 3, "array orco");
- for (int i = 0; i < sculpt_mesh->totvert; i++) {
- copy_v3_v3(ss->cache->array_orco[i], sculpt_mesh->mvert[i].co);
- }
- }
- */
-
-
+ sculpt_array_ensure_original_coordinates(ob, ss->cache->array);
sculpt_array_update(ob, brush, ss->cache->array);
sculpt_array_deform(sd, ob, nodes, totnode);
More information about the Bf-blender-cvs
mailing list