diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:26:11 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:26:11 +0400 |
commit | 31f978c8efdfd88d2cf2b5d9ae7c5d91c81e13d3 (patch) | |
tree | 64203b4b8e556adfa7a77998cbd8d45e36796d4d /source/blender/blenkernel | |
parent | ec258542e2b537c4292fd9214d898fa5d3864ef9 (diff) |
Move layer displacements from SculptUndoNode to PBVHNode
* This doesn't make much difference for regular mesh/multires
sculpting, but for dynamic topology sculpting the undo stack isn't
split up by PBVH nodes, so it's more convenient to store the layer
data in PBVH nodes.
* Note that the life cycle of the layer displacement data is
unchanged -- it's only valid during a stroke with the layer brush,
gets free'd when the undo step ends.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_pbvh.h | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pbvh_intern.h | 3 |
3 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 302de593963..5b6acdb9752 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -156,6 +156,14 @@ void BLI_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems, struct DMGridAdjacency *gridadj, void **gridfaces, struct DMFlagMat *flagmats, unsigned int **grid_hidden); +/* Layer displacement */ + +/* Get the node's displacement layer, creating it if necessary */ +float *BLI_pbvh_node_layer_disp_get(PBVH *pbvh, PBVHNode *node); + +/* If the node has a displacement layer, free it and set to null */ +void BLI_pbvh_node_layer_disp_free(PBVHNode *node); + /* vertex deformer */ float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3]; void BLI_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3]); diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 4341e701810..e9009050d4b 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -600,6 +600,7 @@ void BLI_pbvh_free(PBVH *bvh) MEM_freeN(node->vert_indices); if (node->face_vert_indices) MEM_freeN(node->face_vert_indices); + BLI_pbvh_node_layer_disp_free(node); } } @@ -1611,6 +1612,26 @@ void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, } } +/* Get the node's displacement layer, creating it if necessary */ +float *BLI_pbvh_node_layer_disp_get(PBVH *bvh, PBVHNode *node) +{ + if (!node->layer_disp) { + int totvert = 0; + BLI_pbvh_node_num_verts(bvh, node, &totvert, NULL); + node->layer_disp = MEM_callocN(sizeof(float) * totvert, "layer disp"); + } + return node->layer_disp; +} + +/* If the node has a displacement layer, free it and set to null */ +void BLI_pbvh_node_layer_disp_free(PBVHNode *node) +{ + if (node->layer_disp) { + MEM_freeN(node->layer_disp); + node->layer_disp = NULL; + } +} + float (*BLI_pbvh_get_vertCos(PBVH * pbvh))[3] { int a; diff --git a/source/blender/blenkernel/intern/pbvh_intern.h b/source/blender/blenkernel/intern/pbvh_intern.h index fe996536609..d3539245d11 100644 --- a/source/blender/blenkernel/intern/pbvh_intern.h +++ b/source/blender/blenkernel/intern/pbvh_intern.h @@ -91,6 +91,9 @@ struct PBVHNode { /* Used for raycasting: how close bb is to the ray point. */ float tmin; + /* Scalar displacements for sculpt mode's layer brush. */ + float *layer_disp; + int proxy_count; PBVHProxyNode *proxies; }; |