[Bf-blender-cvs] [a99c4c72907] greasepencil-object: Cleanup: Move ED_gpencil_stroke_minmax() to blenkernel
Joshua Leung
noreply at git.blender.org
Wed Jan 31 05:28:04 CET 2018
Commit: a99c4c729071efb05f1ff0e0b4658eed649d4653
Author: Joshua Leung
Date: Wed Jan 31 17:06:21 2018 +1300
Branches: greasepencil-object
https://developer.blender.org/rBa99c4c729071efb05f1ff0e0b4658eed649d4653
Cleanup: Move ED_gpencil_stroke_minmax() to blenkernel
The rest of the boundbox/minmax code is already there. We might as well
have the function for grabbing this info from a single stroke there too.
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/editors/include/ED_gpencil.h
M source/blender/editors/space_view3d/view3d_edit.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 1118664aefa..856dea662fa 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -179,6 +179,10 @@ void BKE_gpencil_palettecolor_changename(struct PaletteColor *palcolor, struct b
void BKE_gpencil_palettecolor_delete_allstrokes(struct Main *bmain, struct PaletteColor *palcolor);
/* object boundbox */
+bool BKE_gpencil_stroke_minmax(
+ const struct bGPDstroke *gps, const bool use_select,
+ float r_min[3], float r_max[3]);
+
struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob);
void BKE_gpencil_centroid_3D(struct bGPdata *gpd, float r_centroid[3]);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 47554c533d7..5440897a07e 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -2206,22 +2206,44 @@ void BKE_gpencil_move_animdata_to_palettes(bContext *C, bGPdata *gpd)
/* ************************************************** */
/* GP Object - Boundbox Support */
-/* get stroke min max values */
-static void gpencil_minmax(bGPdata *gpd, float min[3], float max[3])
+/**
+ * Get min/max coordinate bounds for single stroke
+ * \return Returns whether we found any selected points
+ */
+bool BKE_gpencil_stroke_minmax(
+ const bGPDstroke *gps, const bool use_select,
+ float r_min[3], float r_max[3])
{
+ const bGPDspoint *pt;
int i;
- bGPDspoint *pt;
- bGPDframe *gpf;
- INIT_MINMAX(min, max);
+ bool changed = false;
+
+ if (ELEM(NULL, gps, r_min, r_max))
+ return false;
+
+ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
+ if ((use_select == false) || (pt->flag & GP_SPOINT_SELECT)) {
+ minmax_v3v3_v3(r_min, r_max, &pt->x);
+ changed = true;
+ }
+ }
+ return changed;
+}
+/* get min/max bounds of all strokes in GP datablock */
+static void gpencil_minmax(bGPdata *gpd, float r_min[3], float r_max[3])
+{
+ INIT_MINMAX(r_min, r_max);
+
+ if (gpd == NULL)
+ return;
+
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- gpf = gpl->actframe;
- if (!gpf) {
- continue;
- }
- for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- minmax_v3v3_v3(min, max, &pt->x);
+ bGPDframe *gpf = gpl->actframe;
+
+ if (gpf != NULL) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ BKE_gpencil_stroke_minmax(gps, false, r_min, r_max);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index e29d40ebb39..6a7cc09b3e6 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1201,25 +1201,6 @@ void ED_gpencil_reset_layers_parent(Object *obact, bGPdata *gpd)
/* ******************************************************** */
/* GP Object Stuff */
-// XXX: Should this be added to blenkernel? Doesn't something like this exist there already?
-bool ED_gpencil_stroke_minmax(
- const bGPDstroke *gps, const bool use_select,
- float r_min[3], float r_max[3])
-{
- const bGPDspoint *pt;
- int i;
- bool changed = false;
-
- for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
- if ((use_select == false) || (pt->flag & GP_SPOINT_SELECT)) {;
- minmax_v3v3_v3(r_min, r_max, &pt->x);
- changed = true;
- }
- }
- return changed;
-}
-
-
/* Helper function to create new OB_GPENCIL Object */
Object *ED_add_gpencil_object(bContext *C, Scene *scene, const float loc[3])
{
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index c05a3ff049f..a3f4be72a3b 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -116,10 +116,6 @@ bool ED_gpencil_stroke_can_use_direct(const struct ScrArea *sa, const struct bGP
bool ED_gpencil_stroke_can_use(const struct bContext *C, const struct bGPDstroke *gps);
bool ED_gpencil_stroke_color_use(const struct bGPDlayer *gpl, const struct bGPDstroke *gps);
-bool ED_gpencil_stroke_minmax(
- const struct bGPDstroke *gps, const bool use_select,
- float r_min[3], float r_max[3]);
-
/* ----------- Grease Pencil Operators ----------------- */
void ED_keymap_gpencil(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 9ef67ab7849..d3d3919ff87 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -52,6 +52,7 @@
#include "BKE_camera.h"
#include "BKE_context.h"
#include "BKE_font.h"
+#include "BKE_gpencil.h"
#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_object.h"
@@ -75,7 +76,6 @@
#include "ED_screen.h"
#include "ED_transform.h"
#include "ED_mesh.h"
-#include "ED_gpencil.h"
#include "ED_view3d.h"
#include "UI_resources.h"
@@ -2836,9 +2836,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
{
/* we're only interested in selected points here... */
if ((gps->flag & GP_STROKE_SELECT) && (gps->flag & GP_STROKE_3DSPACE)) {
- if (ED_gpencil_stroke_minmax(gps, true, min, max)) {
- ok = true;
- }
+ ok |= BKE_gpencil_stroke_minmax(gps, true, min, max);
}
}
CTX_DATA_END;
More information about the Bf-blender-cvs
mailing list