diff options
author | Lukas Tönne <lukas.toenne@gmail.com> | 2017-12-19 17:35:00 +0300 |
---|---|---|
committer | Lukas Tönne <lukas.toenne@gmail.com> | 2017-12-19 17:35:00 +0300 |
commit | 61fae8440dbca3fcbaea499309e325e9df46a7a9 (patch) | |
tree | 898a306079b4642149f2ee27f17bd20198b066b6 /source/blender | |
parent | b3c59d51e034ac1679818b9df51fa3e37b9fd2ed (diff) |
Edit mode data functions for creating, applying a freeing groom edit data.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/groom.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/editors/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/groom/CMakeLists.txt | 47 | ||||
-rw-r--r-- | source/blender/editors/groom/editgroom.c | 117 | ||||
-rw-r--r-- | source/blender/editors/groom/groom_intern.h | 37 | ||||
-rw-r--r-- | source/blender/editors/groom/groom_ops.c | 76 | ||||
-rw-r--r-- | source/blender/editors/include/ED_groom.h | 55 | ||||
-rw-r--r-- | source/blender/editors/include/ED_screen.h | 1 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 8 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_api/spacetypes.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_groom_types.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 1 |
15 files changed, 364 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/groom.c b/source/blender/blenkernel/intern/groom.c index d4f0fd4f832..0e7fe7c6397 100644 --- a/source/blender/blenkernel/intern/groom.c +++ b/source/blender/blenkernel/intern/groom.c @@ -83,14 +83,14 @@ static void groom_bundles_free(ListBase *bundles) /** Free (or release) any data used by this groom (does not free the groom itself). */ void BKE_groom_free(Groom *groom) { - if (groom->edit_groom) + if (groom->editgroom) { - EditGroom *edit = groom->edit_groom; + EditGroom *edit = groom->editgroom; groom_bundles_free(&edit->bundles); MEM_freeN(edit); - groom->edit_groom = NULL; + groom->editgroom = NULL; } MEM_SAFE_FREE(groom->bb); @@ -114,7 +114,7 @@ void BKE_groom_copy_data(Main *UNUSED(bmain), Groom *groom_dst, const Groom *gro BLI_duplicatelist(&groom_dst->bundles, &groom_src->bundles); - groom_dst->edit_groom = NULL; + groom_dst->editgroom = NULL; } Groom *BKE_groom_copy(Main *bmain, const Groom *groom) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a8d2a7e3e7d..ab09ccf5654 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -540,7 +540,7 @@ bool BKE_object_is_in_editmode(Object *ob) } else if (ob->type == OB_GROOM) { Groom *groom = ob->data; - if (groom->edit_groom) + if (groom->editgroom) return true; } return false; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 0f1a8e989ef..2a3920eb936 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -8403,7 +8403,7 @@ static void direct_link_groom(FileData *fd, Groom *groom) groom->bb = NULL; - groom->edit_groom = NULL; + groom->editgroom = NULL; } /* ************** GENERAL & MAIN ******************** */ diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index 757fca0a1b2..00b514d1a15 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -27,6 +27,7 @@ if(WITH_BLENDER) add_subdirectory(armature) add_subdirectory(curve) add_subdirectory(gpencil) + add_subdirectory(groom) add_subdirectory(interface) add_subdirectory(io) add_subdirectory(manipulator_library) diff --git a/source/blender/editors/groom/CMakeLists.txt b/source/blender/editors/groom/CMakeLists.txt new file mode 100644 index 00000000000..695b3846aaa --- /dev/null +++ b/source/blender/editors/groom/CMakeLists.txt @@ -0,0 +1,47 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contributor(s): Lukas Toenne. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + ../include + ../../blenkernel + ../../blenlib + ../../blentranslation + ../../depsgraph + ../../makesdna + ../../makesrna + ../../windowmanager + ../../../../intern/guardedalloc +) + +set(INC_SYS +) + +set(SRC + groom_ops.c + editgroom.c + + groom_intern.h +) + +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + +blender_add_lib(bf_editor_groom "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/groom/editgroom.c b/source/blender/editors/groom/editgroom.c new file mode 100644 index 00000000000..cfb129b6f64 --- /dev/null +++ b/source/blender/editors/groom/editgroom.c @@ -0,0 +1,117 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Toenne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/groom/editgroom.c + * \ingroup edgroom + */ + +#include "DNA_groom_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#include "MEM_guardedalloc.h" + +#include "BLI_array_utils.h" +#include "BLI_blenlib.h" + +#include "BKE_context.h" +#include "BKE_global.h" +#include "BKE_groom.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_report.h" + +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_groom.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_types.h" +#include "ED_util.h" + +#include "groom_intern.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_enum_types.h" + +/********************** Load/Make/Free ********************/ + +static void groom_bundles_free(ListBase *bundles) +{ + for (GroomBundle *bundle = bundles->first; bundle; bundle = bundle->next) + { + BLI_freelistN(&bundle->sections); + } + BLI_freelistN(bundles); +} + +static void groom_bundles_copy(ListBase *bundles_dst, ListBase *bundles_src) +{ + BLI_duplicatelist(bundles_dst, bundles_src); + for (GroomBundle *bundle = bundles_dst->first; bundle; bundle = bundle->next) + { + BLI_duplicatelist(&bundle->sections, &bundle->sections); + } +} + +void ED_groom_editgroom_make(Object *obedit) +{ + Groom *groom = obedit->data; + + ED_groom_editgroom_free(obedit); + + groom->editgroom = MEM_callocN(sizeof(EditGroom), "editgroom"); + groom_bundles_copy(&groom->editgroom->bundles, &groom->bundles); +} + +void ED_groom_editgroom_load(Object *obedit) +{ + Groom *groom = obedit->data; + + groom_bundles_free(&groom->bundles); + groom_bundles_copy(&groom->bundles, &groom->editgroom->bundles); +} + +void ED_groom_editgroom_free(Object *ob) +{ + Groom *groom = ob->data; + + if (groom->editgroom) { + groom_bundles_free(&groom->editgroom->bundles); + + MEM_freeN(groom->editgroom); + groom->editgroom = NULL; + } +} diff --git a/source/blender/editors/groom/groom_intern.h b/source/blender/editors/groom/groom_intern.h new file mode 100644 index 00000000000..336b82fb73e --- /dev/null +++ b/source/blender/editors/groom/groom_intern.h @@ -0,0 +1,37 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Toenne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/groom/groom_intern.h + * \ingroup edgroom + */ + + +#ifndef __GROOM_INTERN_H__ +#define __GROOM_INTERN_H__ + + +#endif /* __GROOM_INTERN_H__ */ diff --git a/source/blender/editors/groom/groom_ops.c b/source/blender/editors/groom/groom_ops.c new file mode 100644 index 00000000000..73a4f40c0ce --- /dev/null +++ b/source/blender/editors/groom/groom_ops.c @@ -0,0 +1,76 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Toenne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/editors/groom/groom_ops.c + * \ingroup edgroom + */ + + +#include <stdlib.h> +#include <math.h> + +#include "DNA_groom_types.h" +#include "DNA_scene_types.h" + +#include "RNA_access.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_groom.h" +#include "ED_object.h" +#include "ED_screen.h" +#include "ED_transform.h" + +#include "groom_intern.h" + +/************************* registration ****************************/ + +void ED_operatortypes_groom(void) +{ +} + +void ED_operatormacros_groom(void) +{ + wmOperatorType *ot; + wmOperatorTypeMacro *otmacro; + + UNUSED_VARS(ot, otmacro); +} + +void ED_keymap_groom(wmKeyConfig *keyconf) +{ + wmKeyMap *keymap; + wmKeyMapItem *kmi; + UNUSED_VARS(kmi); + + keymap = WM_keymap_find(keyconf, "Groom", 0, 0); + keymap->poll = ED_operator_editgroom; + + ED_keymap_proportional_cycle(keyconf, keymap); + ED_keymap_proportional_editmode(keyconf, keymap, true); +} diff --git a/source/blender/editors/include/ED_groom.h b/source/blender/editors/include/ED_groom.h new file mode 100644 index 00000000000..ee6ae7b5d1e --- /dev/null +++ b/source/blender/editors/include/ED_groom.h @@ -0,0 +1,55 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Lukas Toenne + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file ED_groom.h + * \ingroup editors + */ + +#ifndef __ED_GROOM_H__ +#define __ED_GROOM_H__ + +struct bContext; +struct Groom; +struct Object; +struct wmOperator; +struct wmKeyConfig; +struct EditGroom; + +/* groom_ops.c */ +void ED_operatortypes_groom(void); +void ED_operatormacros_groom(void); +void ED_keymap_groom(struct wmKeyConfig *keyconf); + +/* editgroom.c */ +void undo_push_groom(struct bContext *C, const char *name); +ListBase *object_editgroom_get(struct Object *ob); + +void ED_groom_editgroom_load(struct Object *obedit); +void ED_groom_editgroom_make(struct Object *obedit); +void ED_groom_editgroom_free(struct Object *obedit); + +#endif /* __ED_GROOM_H__ */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 89a6828a59d..dadc0577a00 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -244,6 +244,7 @@ int ED_operator_editsurfcurve_region_view3d(struct bContext *C); int ED_operator_editfont(struct bContext *C); int ED_operator_editlattice(struct bContext *C); int ED_operator_editmball(struct bContext *C); +int ED_operator_editgroom(struct bContext *C); int ED_operator_uvedit(struct bContext *C); int ED_operator_uvedit_space_image(struct bContext *C); int ED_operator_uvmap(struct bContext *C); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 87c253f33b2..02d08924d79 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -90,6 +90,7 @@ #include "ED_armature.h" #include "ED_curve.h" +#include "ED_groom.h" #include "ED_mesh.h" #include "ED_mball.h" #include "ED_lattice.h" @@ -396,6 +397,13 @@ void ED_object_editmode_enter(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_CURVE, scene); } + else if (ob->type == OB_GROOM) { + scene->obedit = ob; /* XXX for context */ + ok = 1; + ED_groom_editgroom_make(ob); + + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_EDITMODE_GROOM, scene); + } if (ok) { DEG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4460ac7d1a7..ce30df6e27a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -44,6 +44,7 @@ #include "DNA_object_types.h" #include "DNA_curve_types.h" #include "DNA_gpencil_types.h" +#include "DNA_groom_types.h" #include "DNA_scene_types.h" #include "DNA_meta_types.h" #include "DNA_mask_types.h" @@ -555,6 +556,14 @@ int ED_operator_editmball(bContext *C) return 0; } +int ED_operator_editgroom(bContext *C) +{ + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_GROOM) + return NULL != ((Groom *)obedit->data)->editgroom; + return 0; +} + int ED_operator_mask(bContext *C) { ScrArea *sa = CTX_wm_area(C); diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index e417026640e..60b6bd0cd0b 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -48,6 +48,7 @@ #include "ED_curve.h" #include "ED_fileselect.h" #include "ED_gpencil.h" +#include "ED_groom.h" #include "ED_markers.h" #include "ED_mesh.h" #include "ED_node.h" @@ -122,7 +123,8 @@ void ED_spacetypes_init(void) ED_operatortypes_logic(); ED_operatortypes_mask(); ED_operatortypes_io(); - + ED_operatortypes_groom(); + ED_operatortypes_view2d(); ED_operatortypes_ui(); @@ -173,6 +175,7 @@ void ED_spacemacros_init(void) ED_operatormacros_sequencer(); ED_operatormacros_paint(); ED_operatormacros_gpencil(); + ED_operatormacros_groom(); /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); @@ -205,6 +208,7 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf) ED_keymap_paint(keyconf); ED_keymap_mask(keyconf); ED_keymap_marker(keyconf); + ED_keymap_groom(keyconf); ED_keymap_view2d(keyconf); ED_keymap_ui(keyconf); diff --git a/source/blender/makesdna/DNA_groom_types.h b/source/blender/makesdna/DNA_groom_types.h index e3e669cdf88..fe650fcf43c 100644 --- a/source/blender/makesdna/DNA_groom_types.h +++ b/source/blender/makesdna/DNA_groom_types.h @@ -69,7 +69,7 @@ typedef struct Groom { ListBase bundles; /* List of GroomBundle */ - EditGroom *edit_groom; + EditGroom *editgroom; } Groom; #ifdef __cplusplus diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 71a425bed9b..e2ad2b27702 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -392,6 +392,7 @@ typedef struct wmNotifier { #define NS_EDITMODE_ARMATURE (8<<8) #define NS_MODE_POSE (9<<8) #define NS_MODE_PARTICLE (10<<8) +#define NS_EDITMODE_GROOM (11<<8) /* subtype 3d view editing */ #define NS_VIEW3D_GPU (16<<8) |