[Bf-blender-cvs] [c78ebf9f26d] master: Cleanup: split lattice into own library
Campbell Barton
noreply at git.blender.org
Mon Mar 19 15:45:54 CET 2018
Commit: c78ebf9f26d01fcc3cf16baa9da922ee183f4b09
Author: Campbell Barton
Date: Mon Mar 19 14:49:59 2018 +0100
Branches: master
https://developer.blender.org/rBc78ebf9f26d01fcc3cf16baa9da922ee183f4b09
Cleanup: split lattice into own library
Was mixed with object functionality.
===================================================================
M build_files/cmake/macros.cmake
M doc/doxygen/doxygen.source.h
A source/blender/blenkernel/BKE_editlattice.h
M source/blender/blenkernel/CMakeLists.txt
A source/blender/blenkernel/intern/editlattice.c
M source/blender/editors/CMakeLists.txt
M source/blender/editors/include/ED_lattice.h
M source/blender/editors/include/ED_object.h
A source/blender/editors/lattice/CMakeLists.txt
R050 source/blender/editors/object/object_lattice.c source/blender/editors/lattice/editlattice_select.c
A source/blender/editors/lattice/editlattice_tools.c
A source/blender/editors/lattice/editlattice_undo.c
A source/blender/editors/lattice/lattice_intern.h
A source/blender/editors/lattice/lattice_ops.c
M source/blender/editors/object/CMakeLists.txt
M source/blender/editors/object/object_edit.c
M source/blender/editors/object/object_intern.h
M source/blender/editors/object/object_ops.c
M source/blender/editors/space_api/spacetypes.c
M source/blender/editors/space_view3d/view3d_select.c
M source/blender/editors/util/undo.c
M source/blender/makesrna/intern/rna_object.c
M source/blenderplayer/bad_level_call_stubs/stubs.c
===================================================================
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index eaf8c2b845b..f4d37c192ba 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -588,6 +588,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_editor_mesh
bf_editor_metaball
bf_editor_object
+ bf_editor_lattice
bf_editor_armature
bf_editor_physics
bf_editor_render
diff --git a/doc/doxygen/doxygen.source.h b/doc/doxygen/doxygen.source.h
index 67e231212c7..16ebe407f5f 100644
--- a/doc/doxygen/doxygen.source.h
+++ b/doc/doxygen/doxygen.source.h
@@ -196,6 +196,10 @@
* \ingroup editors
*/
+/** \defgroup edlattice lattice
+ * \ingroup editors
+ */
+
/** \defgroup edmesh mesh
* \ingroup editors
*/
diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/blenkernel/BKE_editlattice.h
similarity index 61%
copy from source/blender/editors/include/ED_lattice.h
copy to source/blender/blenkernel/BKE_editlattice.h
index 30d66577770..476cf535e97 100644
--- a/source/blender/editors/include/ED_lattice.h
+++ b/source/blender/blenkernel/BKE_editlattice.h
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -15,26 +15,20 @@
* 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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
* ***** END GPL LICENSE BLOCK *****
*/
-/** \file ED_lattice.h
- * \ingroup editors
+/** \file BKE_editlattice.h
+ * \ingroup bke
*/
-#ifndef __ED_LATTICE_H__
-#define __ED_LATTICE_H__
+#ifndef __BKE_EDITLATTICE_H__
+#define __BKE_EDITLATTICE_H__
struct Object;
-void ED_lattice_editlatt_free(struct Object *ob);
-void ED_lattice_editlatt_make(struct Object *obedit);
-void ED_lattice_editlatt_load(struct Object *obedit);
+void BKE_editlattice_free(struct Object *ob);
+void BKE_editlattice_make(struct Object *obedit);
+void BKE_editlattice_load(struct Object *obedit);
-#endif /* __ED_LATTICE_H__ */
+#endif /* __BKE_EDITLATTICE_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 6ddc12e435b..231810aee31 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -102,6 +102,7 @@ set(SRC
intern/displist.c
intern/dynamicpaint.c
intern/editderivedmesh.c
+ intern/editlattice.c
intern/editmesh.c
intern/editmesh_bvh.c
intern/effect.c
@@ -230,6 +231,7 @@ set(SRC
BKE_depsgraph.h
BKE_displist.h
BKE_dynamicpaint.h
+ BKE_editlattice.h
BKE_editmesh.h
BKE_editmesh_bvh.h
BKE_effect.h
diff --git a/source/blender/blenkernel/intern/editlattice.c b/source/blender/blenkernel/intern/editlattice.c
new file mode 100644
index 00000000000..cef3c970c7a
--- /dev/null
+++ b/source/blender/blenkernel/intern/editlattice.c
@@ -0,0 +1,147 @@
+/*
+ * ***** 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/editlattice.c
+ * \ingroup bke
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+#include "DNA_object_types.h"
+#include "DNA_key_types.h"
+#include "DNA_lattice_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_curve_types.h"
+
+#include "BLI_math_vector.h"
+#include "BLI_listbase.h"
+
+#include "BKE_deform.h"
+#include "BKE_key.h"
+
+#include "BKE_editlattice.h" /* own include */
+
+void BKE_editlattice_free(Object *ob)
+{
+ Lattice *lt = ob->data;
+
+ if (lt->editlatt) {
+ Lattice *editlt = lt->editlatt->latt;
+
+ if (editlt->def) {
+ MEM_freeN(editlt->def);
+ }
+ if (editlt->dvert) {
+ BKE_defvert_array_free(editlt->dvert, editlt->pntsu * editlt->pntsv * editlt->pntsw);
+ }
+ MEM_freeN(editlt);
+ MEM_freeN(lt->editlatt);
+
+ lt->editlatt = NULL;
+ }
+}
+
+void BKE_editlattice_make(Object *obedit)
+{
+ Lattice *lt = obedit->data;
+ KeyBlock *actkey;
+
+ BKE_editlattice_free(obedit);
+
+ actkey = BKE_keyblock_from_object(obedit);
+ if (actkey) {
+ BKE_keyblock_convert_to_lattice(actkey, lt);
+ }
+ lt->editlatt = MEM_callocN(sizeof(EditLatt), "editlatt");
+ lt->editlatt->latt = MEM_dupallocN(lt);
+ lt->editlatt->latt->def = MEM_dupallocN(lt->def);
+
+ if (lt->dvert) {
+ int tot = lt->pntsu * lt->pntsv * lt->pntsw;
+ lt->editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
+ BKE_defvert_array_copy(lt->editlatt->latt->dvert, lt->dvert, tot);
+ }
+
+ if (lt->key) {
+ lt->editlatt->shapenr = obedit->shapenr;
+ }
+}
+
+void BKE_editlattice_load(Object *obedit)
+{
+ Lattice *lt, *editlt;
+ KeyBlock *actkey;
+ BPoint *bp;
+ float *fp;
+ int tot;
+
+ lt = obedit->data;
+ editlt = lt->editlatt->latt;
+
+ if (lt->editlatt->shapenr) {
+ actkey = BLI_findlink(<->key->block, lt->editlatt->shapenr - 1);
+
+ /* active key: vertices */
+ tot = editlt->pntsu * editlt->pntsv * editlt->pntsw;
+
+ if (actkey->data) {
+ MEM_freeN(actkey->data);
+ }
+
+ fp = actkey->data = MEM_callocN(lt->key->elemsize * tot, "actkey->data");
+ actkey->totelem = tot;
+
+ bp = editlt->def;
+ while (tot--) {
+ copy_v3_v3(fp, bp->vec);
+ fp += 3;
+ bp++;
+ }
+ }
+ else {
+ MEM_freeN(lt->def);
+
+ lt->def = MEM_dupallocN(editlt->def);
+
+ lt->flag = editlt->flag;
+
+ lt->pntsu = editlt->pntsu;
+ lt->pntsv = editlt->pntsv;
+ lt->pntsw = editlt->pntsw;
+
+ lt->typeu = editlt->typeu;
+ lt->typev = editlt->typev;
+ lt->typew = editlt->typew;
+ lt->actbp = editlt->actbp;
+ }
+
+ if (lt->dvert) {
+ BKE_defvert_array_free(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw);
+ lt->dvert = NULL;
+ }
+
+ if (editlt->dvert) {
+ tot = lt->pntsu * lt->pntsv * lt->pntsw;
+
+ lt->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Lattice MDeformVert");
+ BKE_defvert_array_copy(lt->dvert, editlt->dvert, tot);
+ }
+}
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 1559512d713..be8829b0418 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -29,6 +29,7 @@ if(WITH_BLENDER)
add_subdirectory(gpencil)
add_subdirectory(interface)
add_subdirectory(io)
+ add_subdirectory(lattice)
add_subdirectory(mask)
add_subdirectory(mesh)
add_subdirectory(metaball)
diff --git a/source/blender/editors/include/ED_lattice.h b/source/blender/editors/include/ED_lattice.h
index 30d66577770..b652fb4c00b 100644
--- a/source/blender/editors/include/ED_lattice.h
+++ b/source/blender/editors/include/ED_lattice.h
@@ -4,7 +4,7 @@
* 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.
+ * 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
@@ -18,7 +18,6 @@
* The Original Code is Copyright (C) 2008 Blender Foundation.
* All rights reserved.
*
- *
* Contributor(s): Blender Foundation
*
* ***** END GPL LICENSE BLOCK *****
@@ -31,10 +30,17 @@
#ifndef __ED_LATTICE_H__
#define __ED_LATTICE_H__
-struct Object;
+struct wmKeyConfig;
-void ED_lattice_editlatt_free(struct Object *ob);
-void ED_lattice_editlatt_make(struct Object *obedit);
-void ED_lattice_editlatt_load(struct Object *obedit);
+/* lattice_ops.c */
+void ED_operatortypes_lattice(void);
+void ED_keymap_lattice(struct wmKeyConfig *keyconf);
+
+/* editlattice_select.c */
+void ED_lattice_flags_set(struct Object *obedit, int flag);
+bool ED_lattice_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
+
+/* editlattice_undo.c */
+void undo_push_lattice(struct bContext *C, const char *name);
#endif /* __ED_LATTICE_H__ */
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index dcc6d064f92..5b2fdf29dd5 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -192,14 +192,6 @@ void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *o
void ED_object_constraint_tag_update(struct Object *ob, struct bConstraint *con);
void ED_object_constraint_dependency_tag_update(struct Main *bmain, struct Object *ob, struct bConstraint *con);
-/* object_lattice.c */
-bool ED_lattice_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
-void undo_push_lattice(struct bContext *C, const char *name);
-
-/* object_lattice.c */
-
-void ED_lattice_flags_set(struct Object *obedit, int flag);
-
/* object_modes.c */
bool ED_object_mode_compat_test(const struct Object *ob, eObjectMode mode);
bool ED_object_mode_compat_set(struct bContext *C, struct Object *ob, eObjectMode mode, struct ReportList *reports);
diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/lattice/CMake
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list