Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2018-10-09 17:55:13 +0300
committerAntonioya <blendergit@gmail.com>2018-10-09 17:55:29 +0300
commit90e360c39fbe9ea0f9d0a441001d0dccfb158d04 (patch)
tree5ee36a806a45483840010447ce40d7b7a513f3d8 /source/blender/blenkernel/intern/gpencil.c
parent5cb633ce3f6c7459faab085134b6dcdbf010da4b (diff)
GP: Improve center object in viewport when press .
Before when press . (view_select) the object was centered at the dummy, but now it's centered with the strokes bounding box size. Also fixed some problems in edit mode when the object origin was not in view origin.
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index ae78dd8d175..559d4ef3bef 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1088,8 +1088,8 @@ Material *BKE_gpencil_material_ensure(Main *bmain, Object *ob)
* \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 bGPDstroke *gps, const bool use_select,
+ float r_min[3], float r_max[3])
{
const bGPDspoint *pt;
int i;
@@ -1108,22 +1108,35 @@ bool BKE_gpencil_stroke_minmax(
}
/* get min/max bounds of all strokes in GP datablock */
-static void gpencil_minmax(bGPdata *gpd, float r_min[3], float r_max[3])
+bool BKE_gpencil_data_minmax(Object *ob, const bGPdata *gpd, float r_min[3], float r_max[3])
{
+ float bmat[3][3];
+ bool changed = false;
+
INIT_MINMAX(r_min, r_max);
if (gpd == NULL)
- return;
+ return changed;
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
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);
+ changed = BKE_gpencil_stroke_minmax(gps, false, r_min, r_max);
}
}
}
+
+ if ((changed) && (ob)) {
+ copy_m3_m4(bmat, ob->obmat);
+ mul_m3_v3(bmat, r_min);
+ add_v3_v3(r_min, ob->obmat[3]);
+ mul_m3_v3(bmat, r_max);
+ add_v3_v3(r_max, ob->obmat[3]);
+ }
+
+ return changed;
}
/* compute center of bounding box */
@@ -1131,7 +1144,7 @@ void BKE_gpencil_centroid_3D(bGPdata *gpd, float r_centroid[3])
{
float min[3], max[3], tot[3];
- gpencil_minmax(gpd, min, max);
+ BKE_gpencil_data_minmax(NULL, gpd, min, max);
add_v3_v3v3(tot, min, max);
mul_v3_v3fl(r_centroid, tot, 0.5f);
@@ -1152,7 +1165,7 @@ static void boundbox_gpencil(Object *ob)
bb = ob->bb;
gpd = ob->data;
- gpencil_minmax(gpd, min, max);
+ BKE_gpencil_data_minmax(NULL, gpd, min, max);
BKE_boundbox_init_from_minmax(bb, min, max);
bb->flag &= ~BOUNDBOX_DIRTY;