Commit: 236353e3854de622ba9221a716e3969acdc95cc4
Author: Antonioya
Date: Sun Mar 10 16:52:43 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB236353e3854de622ba9221a716e3969acdc95cc4
GPencil: Add support to color names for selected strokes
When enable names display in object panel, the color of each selected stroke is
displayed in the viewport near to the first selected stroke.
===================================================================
M source/blender/draw/modes/object_mode.c
===================================================================
diff --git a/source/blender/draw/modes/object_mode.c
b/source/blender/draw/modes/object_mode.c
index f68be196f0e..07ec8f0a11a 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -28,6 +28,7 @@
#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
@@ -2873,6 +2874,56 @@ static void OBJECT_cache_populate_particles(
}
}
+static void OBJECT_gpencil_color_names(Object *ob, struct DRWTextStore *dt,
uchar color[4])
+{
+ bGPdata *gpd = (bGPdata *)ob->data;
+ if (gpd == NULL) {
+ return;
+ }
+
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ if (gpl->flag & GP_LAYER_HIDE) {
+ continue;
+ }
+ bGPDframe *gpf = gpl->actframe;
+ if (gpf == NULL) {
+ continue;
+ }
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps =
gps->next) {
+ Material *ma = give_current_material(ob, gps->mat_nr +
1);
+ if (ma == NULL) {
+ continue;
+ }
+
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ /* skip stroke if it doesn't have any valid data */
+ if ((gps->points == NULL) || (gps->totpoints < 1) ||
(gp_style == NULL)) {
+ continue;
+ }
+ /* check if the color is visible */
+ if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
+ continue;
+ }
+
+ /* only if selected */
+ if (gps->flag & GP_STROKE_SELECT) {
+ float fpt[3];
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ if (pt->flag & GP_SPOINT_SELECT) {
+ mul_v3_m4v3(fpt, ob->obmat,
&pt->x);
+ DRW_text_cache_add(
+ dt, fpt,
+ ma->id.name + 2,
strlen(ma->id.name + 2),
+ 10, 0,
DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
static void OBJECT_cache_populate(void *vedata, Object *ob)
{
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
@@ -3141,6 +3192,11 @@ static void OBJECT_cache_populate(void *vedata, Object
*ob)
dt, ob->obmat[3],
ob->id.name + 2, strlen(ob->id.name + 2),
10, 0, DRW_TEXT_CACHE_GLOBALSPACE |
DRW_TEXT_CACHE_STRING_PTR, color);
+
+ /* draw grease pencil stroke names */
+ if (ob->type == OB_GPENCIL) {
+ OBJECT_gpencil_color_names(ob, dt, color);
+ }
}
if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH,
OB_CURVE, OB_MBALL)) {
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs