Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_uv.c
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| #include "paint_intern.h" | #include "paint_intern.h" | ||||
| #include "uvedit_intern.h" | #include "uvedit_intern.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
merwin: Still need this after converting? | |||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "GPU_immediate.h" | |||||
| #define MARK_BOUNDARY 1 | #define MARK_BOUNDARY 1 | ||||
| typedef struct UvAdjacencyElement { | typedef struct UvAdjacencyElement { | ||||
| /* pointer to original uvelement */ | /* pointer to original uvelement */ | ||||
| UvElement *element; | UvElement *element; | ||||
| /* uv pointer for convenience. Caution, this points to the original UVs! */ | /* uv pointer for convenience. Caution, this points to the original UVs! */ | ||||
| float *uv; | float *uv; | ||||
| /* general use flag (Used to check if Element is boundary here) */ | /* general use flag (Used to check if Element is boundary here) */ | ||||
| ▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| #define PX_SIZE_FADE_MAX 12.0f | #define PX_SIZE_FADE_MAX 12.0f | ||||
| #define PX_SIZE_FADE_MIN 4.0f | #define PX_SIZE_FADE_MIN 4.0f | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| //Brush *brush = image_paint_brush(C); | //Brush *brush = image_paint_brush(C); | ||||
| Paint *paint = BKE_paint_get_active_from_context(C); | Paint *paint = BKE_paint_get_active_from_context(C); | ||||
| Brush *brush = BKE_paint_brush(paint); | Brush *brush = BKE_paint_brush(paint); | ||||
| int i; | |||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { | if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { | ||||
| const float size = (float)BKE_brush_size_get(scene, brush); | const float size = (float)BKE_brush_size_get(scene, brush); | ||||
| float alpha = 0.5f; | float alpha = 0.5f; | ||||
| /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/ | /* fade out the brush (cheap trick to work around brush interfering with sampling [#])*/ | ||||
| if (size < PX_SIZE_FADE_MIN) { | if (size < PX_SIZE_FADE_MIN) { | ||||
| return; | return; | ||||
| } | } | ||||
| else if (size < PX_SIZE_FADE_MAX) { | else if (size < PX_SIZE_FADE_MAX) { | ||||
| alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); | alpha *= (size - PX_SIZE_FADE_MIN) / (PX_SIZE_FADE_MAX - PX_SIZE_FADE_MIN); | ||||
| } | } | ||||
| glPushMatrix(); | glPushMatrix(); | ||||
| glTranslatef((float)x, (float)y, 0.0f); | glTranslatef((float)x, (float)y, 0.0f); | ||||
| glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); | |||||
merwinUnsubmitted Not Done Inline ActionsCould use immUniformColor3fvAlpha(brush->add_col, alpha) merwin: Could use immUniformColor3fvAlpha(brush->add_col, alpha) | |||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glutil_draw_lined_arc(0, (float)(M_PI * 2.0), size, 40); | |||||
| immBegin(PRIM_LINE_STRIP, 40); | |||||
| for(i = 0; i < 40; i++) { | |||||
| float t = (float) i / 39; | |||||
| float cur = t * (float)(M_PI * 2.0); | |||||
| immVertex2f(pos, cosf(cur) * size, sinf(cur) * size); | |||||
| } | |||||
| immEnd(); | |||||
merwinUnsubmitted Not Done Inline ActionsWe have a utility function for this: imm_draw_lined_circle(pos, x, y, size, 40); That would let you get rid of the "int i", glPushMatrix, glTranslatef, and glPopMatrix. Nice! merwin: We have a utility function for this:
imm_draw_lined_circle(pos, x, y, size, 40);
That would… | |||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| glDisable(GL_LINE_SMOOTH); | glDisable(GL_LINE_SMOOTH); | ||||
| immUnbindProgram(); | |||||
| glPopMatrix(); | glPopMatrix(); | ||||
| } | } | ||||
| #undef PX_SIZE_FADE_MAX | #undef PX_SIZE_FADE_MAX | ||||
| #undef PX_SIZE_FADE_MIN | #undef PX_SIZE_FADE_MIN | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 698 Lines • Show Last 20 Lines | |||||
Still need this after converting?