From 9c510330d982d92a7c5b1475200b885fbc5e8f32 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 15 May 2013 08:54:05 +0000 Subject: Move sculptsession functions implementation from object.c to paint.c This functios are declared in BKE_paint.h header and using SculptSession structure which is also declared there. Anyway, does not make sense such a splitting of header and implementation files, better be consistent here. --- source/blender/blenkernel/intern/object.c | 114 ------------------------------ 1 file changed, 114 deletions(-) (limited to 'source/blender/blenkernel/intern/object.c') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a3fa17ceb86..57fd555d57e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -87,7 +87,6 @@ #include "BKE_fcurve.h" #include "BKE_group.h" #include "BKE_icons.h" -#include "BKE_image.h" #include "BKE_key.h" #include "BKE_lamp.h" #include "BKE_lattice.h" @@ -260,119 +259,6 @@ void BKE_object_free_display(Object *ob) BKE_displist_free(&ob->disp); } -void free_sculptsession_deformMats(SculptSession *ss) -{ - if (ss->orig_cos) MEM_freeN(ss->orig_cos); - if (ss->deform_cos) MEM_freeN(ss->deform_cos); - if (ss->deform_imats) MEM_freeN(ss->deform_imats); - - ss->orig_cos = NULL; - ss->deform_cos = NULL; - ss->deform_imats = NULL; -} - -/* Write out the sculpt dynamic-topology BMesh to the Mesh */ -static void sculptsession_bm_to_me_update_data_only(Object *ob, bool reorder) -{ - SculptSession *ss = ob->sculpt; - - if (ss->bm) { - if (ob->data) { - BMIter iter; - BMFace *efa; - BM_ITER_MESH (efa, &iter, ss->bm, BM_FACES_OF_MESH) { - BM_elem_flag_set(efa, BM_ELEM_SMOOTH, - ss->bm_smooth_shading); - } - if (reorder) - BM_log_mesh_elems_reorder(ss->bm, ss->bm_log); - BM_mesh_bm_to_me(ss->bm, ob->data, FALSE); - } - } -} - -void sculptsession_bm_to_me(Object *ob, int reorder) -{ - if (ob && ob->sculpt) { - sculptsession_bm_to_me_update_data_only(ob, reorder); - - /* ensure the objects DerivedMesh mesh doesn't hold onto arrays now realloc'd in the mesh [#34473] */ - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } -} - -void sculptsession_bm_to_me_for_render(Object *object) -{ - if (object && object->sculpt) { - if (object->sculpt->bm) { - /* Ensure no points to old arrays are stored in DM - * - * Apparently, we could not use DAG_id_tag_update - * here because this will lead to the while object - * surface to disappear, so we'll release DM in place. - */ - if (object->derivedFinal) { - object->derivedFinal->needsFree = 1; - object->derivedFinal->release(object->derivedFinal); - object->derivedFinal = NULL; - } - if (object->sculpt->pbvh) { - BKE_pbvh_free(object->sculpt->pbvh); - object->sculpt->pbvh = NULL; - } - - sculptsession_bm_to_me_update_data_only(object, false); - - /* In contrast with sculptsession_bm_to_me no need in - * DAG tag update here - derived mesh was freed and - * old pointers are nowhere stored. - */ - } - } -} - -void free_sculptsession(Object *ob) -{ - if (ob && ob->sculpt) { - SculptSession *ss = ob->sculpt; - DerivedMesh *dm = ob->derivedFinal; - - if (ss->bm) { - sculptsession_bm_to_me(ob, TRUE); - BM_mesh_free(ss->bm); - } - - if (ss->pbvh) - BKE_pbvh_free(ss->pbvh); - if (ss->bm_log) - BM_log_free(ss->bm_log); - - if (dm && dm->getPBVH) - dm->getPBVH(NULL, dm); /* signal to clear */ - - if (ss->texcache) - MEM_freeN(ss->texcache); - - if (ss->tex_pool) - BKE_image_pool_free(ss->tex_pool); - - if (ss->layer_co) - MEM_freeN(ss->layer_co); - - if (ss->orig_cos) - MEM_freeN(ss->orig_cos); - if (ss->deform_cos) - MEM_freeN(ss->deform_cos); - if (ss->deform_imats) - MEM_freeN(ss->deform_imats); - - MEM_freeN(ss); - - ob->sculpt = NULL; - } -} - - /* do not free object itself */ void BKE_object_free(Object *ob) { -- cgit v1.2.3