hexsha
stringlengths
40
40
repo
stringlengths
5
105
path
stringlengths
3
173
license
sequence
language
stringclasses
1 value
identifier
stringlengths
1
438
return_type
stringlengths
1
106
original_string
stringlengths
21
40.7k
original_docstring
stringlengths
18
13.4k
docstring
stringlengths
11
3.24k
docstring_tokens
sequence
code
stringlengths
14
20.4k
code_tokens
sequence
short_docstring
stringlengths
0
4.36k
short_docstring_tokens
sequence
comment
sequence
parameters
list
docstring_params
dict
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_mask_layer_shape_find_frame_range
int
int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const float frame, MaskLayerShape **r_masklay_shape_a, MaskLayerShape **r_masklay_shape_b) { MaskLayerShape *masklay_shape; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (frame == masklay_shape->frame) { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } else if (frame < masklay_shape->frame) { if (masklay_shape->prev) { *r_masklay_shape_a = masklay_shape->prev; *r_masklay_shape_b = masklay_shape; return 2; } else { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } } } if ((masklay_shape = masklay->splines_shapes.last)) { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } else { *r_masklay_shape_a = NULL; *r_masklay_shape_b = NULL; return 0; } }
/** * When returning 2 - the frame isn't found but before/after frames are. */
When returning 2 - the frame isn't found but before/after frames are.
[ "When", "returning", "2", "-", "the", "frame", "isn", "'", "t", "found", "but", "before", "/", "after", "frames", "are", "." ]
int BKE_mask_layer_shape_find_frame_range(MaskLayer *masklay, const float frame, MaskLayerShape **r_masklay_shape_a, MaskLayerShape **r_masklay_shape_b) { MaskLayerShape *masklay_shape; for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (frame == masklay_shape->frame) { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } else if (frame < masklay_shape->frame) { if (masklay_shape->prev) { *r_masklay_shape_a = masklay_shape->prev; *r_masklay_shape_b = masklay_shape; return 2; } else { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } } } if ((masklay_shape = masklay->splines_shapes.last)) { *r_masklay_shape_a = masklay_shape; *r_masklay_shape_b = NULL; return 1; } else { *r_masklay_shape_a = NULL; *r_masklay_shape_b = NULL; return 0; } }
[ "int", "BKE_mask_layer_shape_find_frame_range", "(", "MaskLayer", "*", "masklay", ",", "const", "float", "frame", ",", "MaskLayerShape", "*", "*", "r_masklay_shape_a", ",", "MaskLayerShape", "*", "*", "r_masklay_shape_b", ")", "{", "MaskLayerShape", "*", "masklay_shape", ";", "for", "(", "masklay_shape", "=", "masklay", "->", "splines_shapes", ".", "first", ";", "masklay_shape", ";", "masklay_shape", "=", "masklay_shape", "->", "next", ")", "{", "if", "(", "frame", "==", "masklay_shape", "->", "frame", ")", "{", "*", "r_masklay_shape_a", "=", "masklay_shape", ";", "*", "r_masklay_shape_b", "=", "NULL", ";", "return", "1", ";", "}", "else", "if", "(", "frame", "<", "masklay_shape", "->", "frame", ")", "{", "if", "(", "masklay_shape", "->", "prev", ")", "{", "*", "r_masklay_shape_a", "=", "masklay_shape", "->", "prev", ";", "*", "r_masklay_shape_b", "=", "masklay_shape", ";", "return", "2", ";", "}", "else", "{", "*", "r_masklay_shape_a", "=", "masklay_shape", ";", "*", "r_masklay_shape_b", "=", "NULL", ";", "return", "1", ";", "}", "}", "}", "if", "(", "(", "masklay_shape", "=", "masklay", "->", "splines_shapes", ".", "last", ")", ")", "{", "*", "r_masklay_shape_a", "=", "masklay_shape", ";", "*", "r_masklay_shape_b", "=", "NULL", ";", "return", "1", ";", "}", "else", "{", "*", "r_masklay_shape_a", "=", "NULL", ";", "*", "r_masklay_shape_b", "=", "NULL", ";", "return", "0", ";", "}", "}" ]
When returning 2 - the frame isn't found but before/after frames are.
[ "When", "returning", "2", "-", "the", "frame", "isn", "'", "t", "found", "but", "before", "/", "after", "frames", "are", "." ]
[]
[ { "param": "masklay", "type": "MaskLayer" }, { "param": "frame", "type": "float" }, { "param": "r_masklay_shape_a", "type": "MaskLayerShape" }, { "param": "r_masklay_shape_b", "type": "MaskLayerShape" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "masklay", "type": "MaskLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "frame", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r_masklay_shape_a", "type": "MaskLayerShape", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "r_masklay_shape_b", "type": "MaskLayerShape", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
interp_weights_uv_v2_calc
void
static void interp_weights_uv_v2_calc(float r_uv[2], const float pt[2], const float pt_a[2], const float pt_b[2]) { float pt_on_line[2]; r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b); r_uv[1] = (len_v2v2(pt_on_line, pt) / len_v2v2(pt_a, pt_b)) * /* This line only sets the sign. */ ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f); }
/* basic 2D interpolation functions, could make more comprehensive later */
basic 2D interpolation functions, could make more comprehensive later
[ "basic", "2D", "interpolation", "functions", "could", "make", "more", "comprehensive", "later" ]
static void interp_weights_uv_v2_calc(float r_uv[2], const float pt[2], const float pt_a[2], const float pt_b[2]) { float pt_on_line[2]; r_uv[0] = closest_to_line_v2(pt_on_line, pt, pt_a, pt_b); r_uv[1] = (len_v2v2(pt_on_line, pt) / len_v2v2(pt_a, pt_b)) * ((line_point_side_v2(pt_a, pt_b, pt) < 0.0f) ? -1.0f : 1.0f); }
[ "static", "void", "interp_weights_uv_v2_calc", "(", "float", "r_uv", "[", "2", "]", ",", "const", "float", "pt", "[", "2", "]", ",", "const", "float", "pt_a", "[", "2", "]", ",", "const", "float", "pt_b", "[", "2", "]", ")", "{", "float", "pt_on_line", "[", "2", "]", ";", "r_uv", "[", "0", "]", "=", "closest_to_line_v2", "(", "pt_on_line", ",", "pt", ",", "pt_a", ",", "pt_b", ")", ";", "r_uv", "[", "1", "]", "=", "(", "len_v2v2", "(", "pt_on_line", ",", "pt", ")", "/", "len_v2v2", "(", "pt_a", ",", "pt_b", ")", ")", "*", "(", "(", "line_point_side_v2", "(", "pt_a", ",", "pt_b", ",", "pt", ")", "<", "0.0f", ")", "?", "-1.0f", ":", "1.0f", ")", ";", "}" ]
basic 2D interpolation functions, could make more comprehensive later
[ "basic", "2D", "interpolation", "functions", "could", "make", "more", "comprehensive", "later" ]
[ "/* This line only sets the sign. */" ]
[ { "param": "r_uv", "type": "float" }, { "param": "pt", "type": "float" }, { "param": "pt_a", "type": "float" }, { "param": "pt_b", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "r_uv", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pt", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pt_a", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pt_b", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_mask_layer_shape_changed_add
void
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate) { MaskLayerShape *masklay_shape; /* spline index from masklay */ MaskSpline *spline; int spline_point_index; if (BKE_mask_layer_shape_spline_from_index(masklay, index, &spline, &spline_point_index)) { /* sanity check */ /* The point has already been removed in this array * so subtract one when comparing with the shapes. */ int tot = BKE_mask_layer_shape_totvert(masklay) - 1; /* for interpolation */ /* TODO - assumes closed curve for now */ float uv[3][2]; /* 3x 2D handles */ const int pi_curr = spline_point_index; const int pi_prev = ((spline_point_index - 1) + spline->tot_point) % spline->tot_point; const int pi_next = (spline_point_index + 1) % spline->tot_point; const int index_offset = index - spline_point_index; /* const int pi_curr_abs = index; */ const int pi_prev_abs = pi_prev + index_offset; const int pi_next_abs = pi_next + index_offset; int i; if (do_init_interpolate) { for (i = 0; i < 3; i++) { interp_weights_uv_v2_calc(uv[i], spline->points[pi_curr].bezt.vec[i], spline->points[pi_prev].bezt.vec[i], spline->points[pi_next].bezt.vec[i]); } } for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (tot == masklay_shape->tot_vert) { float *data_resized; masklay_shape->tot_vert++; data_resized = MEM_mallocN( masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (index != masklay_shape->tot_vert - 1) { memcpy(&data_resized[(index + 1) * MASK_OBJECT_SHAPE_ELEM_SIZE], masklay_shape->data + (index * MASK_OBJECT_SHAPE_ELEM_SIZE), (masklay_shape->tot_vert - (index + 1)) * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (do_init) { float *fp = &data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE]; mask_layer_shape_from_mask_point(&spline->points[spline_point_index].bezt, fp); if (do_init_interpolate && spline->tot_point > 2) { for (i = 0; i < 3; i++) { interp_weights_uv_v2_apply( uv[i], &fp[i * 2], &data_resized[(pi_prev_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)], &data_resized[(pi_next_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)]); } } } else { memset(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE], 0, sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } MEM_freeN(masklay_shape->data); masklay_shape->data = data_resized; } else { CLOG_ERROR(&LOG, "vert mismatch %d != %d (frame %d)", masklay_shape->tot_vert, tot, masklay_shape->frame); } } } }
/* when a new points added - resize all shapekey array */
when a new points added - resize all shapekey array
[ "when", "a", "new", "points", "added", "-", "resize", "all", "shapekey", "array" ]
void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, int index, bool do_init, bool do_init_interpolate) { MaskLayerShape *masklay_shape; MaskSpline *spline; int spline_point_index; if (BKE_mask_layer_shape_spline_from_index(masklay, index, &spline, &spline_point_index)) { int tot = BKE_mask_layer_shape_totvert(masklay) - 1; float uv[3][2]; const int pi_curr = spline_point_index; const int pi_prev = ((spline_point_index - 1) + spline->tot_point) % spline->tot_point; const int pi_next = (spline_point_index + 1) % spline->tot_point; const int index_offset = index - spline_point_index; const int pi_prev_abs = pi_prev + index_offset; const int pi_next_abs = pi_next + index_offset; int i; if (do_init_interpolate) { for (i = 0; i < 3; i++) { interp_weights_uv_v2_calc(uv[i], spline->points[pi_curr].bezt.vec[i], spline->points[pi_prev].bezt.vec[i], spline->points[pi_next].bezt.vec[i]); } } for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (tot == masklay_shape->tot_vert) { float *data_resized; masklay_shape->tot_vert++; data_resized = MEM_mallocN( masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (index != masklay_shape->tot_vert - 1) { memcpy(&data_resized[(index + 1) * MASK_OBJECT_SHAPE_ELEM_SIZE], masklay_shape->data + (index * MASK_OBJECT_SHAPE_ELEM_SIZE), (masklay_shape->tot_vert - (index + 1)) * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (do_init) { float *fp = &data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE]; mask_layer_shape_from_mask_point(&spline->points[spline_point_index].bezt, fp); if (do_init_interpolate && spline->tot_point > 2) { for (i = 0; i < 3; i++) { interp_weights_uv_v2_apply( uv[i], &fp[i * 2], &data_resized[(pi_prev_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)], &data_resized[(pi_next_abs * MASK_OBJECT_SHAPE_ELEM_SIZE) + (i * 2)]); } } } else { memset(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE], 0, sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } MEM_freeN(masklay_shape->data); masklay_shape->data = data_resized; } else { CLOG_ERROR(&LOG, "vert mismatch %d != %d (frame %d)", masklay_shape->tot_vert, tot, masklay_shape->frame); } } } }
[ "void", "BKE_mask_layer_shape_changed_add", "(", "MaskLayer", "*", "masklay", ",", "int", "index", ",", "bool", "do_init", ",", "bool", "do_init_interpolate", ")", "{", "MaskLayerShape", "*", "masklay_shape", ";", "MaskSpline", "*", "spline", ";", "int", "spline_point_index", ";", "if", "(", "BKE_mask_layer_shape_spline_from_index", "(", "masklay", ",", "index", ",", "&", "spline", ",", "&", "spline_point_index", ")", ")", "{", "int", "tot", "=", "BKE_mask_layer_shape_totvert", "(", "masklay", ")", "-", "1", ";", "float", "uv", "[", "3", "]", "[", "2", "]", ";", "const", "int", "pi_curr", "=", "spline_point_index", ";", "const", "int", "pi_prev", "=", "(", "(", "spline_point_index", "-", "1", ")", "+", "spline", "->", "tot_point", ")", "%", "spline", "->", "tot_point", ";", "const", "int", "pi_next", "=", "(", "spline_point_index", "+", "1", ")", "%", "spline", "->", "tot_point", ";", "const", "int", "index_offset", "=", "index", "-", "spline_point_index", ";", "const", "int", "pi_prev_abs", "=", "pi_prev", "+", "index_offset", ";", "const", "int", "pi_next_abs", "=", "pi_next", "+", "index_offset", ";", "int", "i", ";", "if", "(", "do_init_interpolate", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "interp_weights_uv_v2_calc", "(", "uv", "[", "i", "]", ",", "spline", "->", "points", "[", "pi_curr", "]", ".", "bezt", ".", "vec", "[", "i", "]", ",", "spline", "->", "points", "[", "pi_prev", "]", ".", "bezt", ".", "vec", "[", "i", "]", ",", "spline", "->", "points", "[", "pi_next", "]", ".", "bezt", ".", "vec", "[", "i", "]", ")", ";", "}", "}", "for", "(", "masklay_shape", "=", "masklay", "->", "splines_shapes", ".", "first", ";", "masklay_shape", ";", "masklay_shape", "=", "masklay_shape", "->", "next", ")", "{", "if", "(", "tot", "==", "masklay_shape", "->", "tot_vert", ")", "{", "float", "*", "data_resized", ";", "masklay_shape", "->", "tot_vert", "++", ";", "data_resized", "=", "MEM_mallocN", "(", "masklay_shape", "->", "tot_vert", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ",", "__func__", ")", ";", "if", "(", "index", ">", "0", ")", "{", "memcpy", "(", "data_resized", ",", "masklay_shape", "->", "data", ",", "index", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ";", "}", "if", "(", "index", "!=", "masklay_shape", "->", "tot_vert", "-", "1", ")", "{", "memcpy", "(", "&", "data_resized", "[", "(", "index", "+", "1", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", "]", ",", "masklay_shape", "->", "data", "+", "(", "index", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ",", "(", "masklay_shape", "->", "tot_vert", "-", "(", "index", "+", "1", ")", ")", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ";", "}", "if", "(", "do_init", ")", "{", "float", "*", "fp", "=", "&", "data_resized", "[", "index", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", "]", ";", "mask_layer_shape_from_mask_point", "(", "&", "spline", "->", "points", "[", "spline_point_index", "]", ".", "bezt", ",", "fp", ")", ";", "if", "(", "do_init_interpolate", "&&", "spline", "->", "tot_point", ">", "2", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "interp_weights_uv_v2_apply", "(", "uv", "[", "i", "]", ",", "&", "fp", "[", "i", "*", "2", "]", ",", "&", "data_resized", "[", "(", "pi_prev_abs", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", "+", "(", "i", "*", "2", ")", "]", ",", "&", "data_resized", "[", "(", "pi_next_abs", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", "+", "(", "i", "*", "2", ")", "]", ")", ";", "}", "}", "}", "else", "{", "memset", "(", "&", "data_resized", "[", "index", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", "]", ",", "0", ",", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ";", "}", "MEM_freeN", "(", "masklay_shape", "->", "data", ")", ";", "masklay_shape", "->", "data", "=", "data_resized", ";", "}", "else", "{", "CLOG_ERROR", "(", "&", "LOG", ",", "\"", "\"", ",", "masklay_shape", "->", "tot_vert", ",", "tot", ",", "masklay_shape", "->", "frame", ")", ";", "}", "}", "}", "}" ]
when a new points added - resize all shapekey array
[ "when", "a", "new", "points", "added", "-", "resize", "all", "shapekey", "array" ]
[ "/* spline index from masklay */", "/* sanity check */", "/* The point has already been removed in this array\n * so subtract one when comparing with the shapes. */", "/* for interpolation */", "/* TODO - assumes closed curve for now */", "/* 3x 2D handles */", "/* const int pi_curr_abs = index; */" ]
[ { "param": "masklay", "type": "MaskLayer" }, { "param": "index", "type": "int" }, { "param": "do_init", "type": "bool" }, { "param": "do_init_interpolate", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "masklay", "type": "MaskLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "do_init", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "do_init_interpolate", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_mask_layer_shape_changed_remove
void
void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int count) { MaskLayerShape *masklay_shape; /* the point has already been removed in this array so add one when comparing with the shapes */ int tot = BKE_mask_layer_shape_totvert(masklay); for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (tot == masklay_shape->tot_vert - count) { float *data_resized; masklay_shape->tot_vert -= count; data_resized = MEM_mallocN( masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (index != masklay_shape->tot_vert) { memcpy(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE], masklay_shape->data + ((index + count) * MASK_OBJECT_SHAPE_ELEM_SIZE), (masklay_shape->tot_vert - index) * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } MEM_freeN(masklay_shape->data); masklay_shape->data = data_resized; } else { CLOG_ERROR(&LOG, "vert mismatch %d != %d (frame %d)", masklay_shape->tot_vert - count, tot, masklay_shape->frame); } } }
/* move array to account for removed point */
move array to account for removed point
[ "move", "array", "to", "account", "for", "removed", "point" ]
void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int count) { MaskLayerShape *masklay_shape; int tot = BKE_mask_layer_shape_totvert(masklay); for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { if (tot == masklay_shape->tot_vert - count) { float *data_resized; masklay_shape->tot_vert -= count; data_resized = MEM_mallocN( masklay_shape->tot_vert * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE, __func__); if (index > 0) { memcpy(data_resized, masklay_shape->data, index * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } if (index != masklay_shape->tot_vert) { memcpy(&data_resized[index * MASK_OBJECT_SHAPE_ELEM_SIZE], masklay_shape->data + ((index + count) * MASK_OBJECT_SHAPE_ELEM_SIZE), (masklay_shape->tot_vert - index) * sizeof(float) * MASK_OBJECT_SHAPE_ELEM_SIZE); } MEM_freeN(masklay_shape->data); masklay_shape->data = data_resized; } else { CLOG_ERROR(&LOG, "vert mismatch %d != %d (frame %d)", masklay_shape->tot_vert - count, tot, masklay_shape->frame); } } }
[ "void", "BKE_mask_layer_shape_changed_remove", "(", "MaskLayer", "*", "masklay", ",", "int", "index", ",", "int", "count", ")", "{", "MaskLayerShape", "*", "masklay_shape", ";", "int", "tot", "=", "BKE_mask_layer_shape_totvert", "(", "masklay", ")", ";", "for", "(", "masklay_shape", "=", "masklay", "->", "splines_shapes", ".", "first", ";", "masklay_shape", ";", "masklay_shape", "=", "masklay_shape", "->", "next", ")", "{", "if", "(", "tot", "==", "masklay_shape", "->", "tot_vert", "-", "count", ")", "{", "float", "*", "data_resized", ";", "masklay_shape", "->", "tot_vert", "-=", "count", ";", "data_resized", "=", "MEM_mallocN", "(", "masklay_shape", "->", "tot_vert", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ",", "__func__", ")", ";", "if", "(", "index", ">", "0", ")", "{", "memcpy", "(", "data_resized", ",", "masklay_shape", "->", "data", ",", "index", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ";", "}", "if", "(", "index", "!=", "masklay_shape", "->", "tot_vert", ")", "{", "memcpy", "(", "&", "data_resized", "[", "index", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", "]", ",", "masklay_shape", "->", "data", "+", "(", "(", "index", "+", "count", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ",", "(", "masklay_shape", "->", "tot_vert", "-", "index", ")", "*", "sizeof", "(", "float", ")", "*", "MASK_OBJECT_SHAPE_ELEM_SIZE", ")", ";", "}", "MEM_freeN", "(", "masklay_shape", "->", "data", ")", ";", "masklay_shape", "->", "data", "=", "data_resized", ";", "}", "else", "{", "CLOG_ERROR", "(", "&", "LOG", ",", "\"", "\"", ",", "masklay_shape", "->", "tot_vert", "-", "count", ",", "tot", ",", "masklay_shape", "->", "frame", ")", ";", "}", "}", "}" ]
move array to account for removed point
[ "move", "array", "to", "account", "for", "removed", "point" ]
[ "/* the point has already been removed in this array so add one when comparing with the shapes */" ]
[ { "param": "masklay", "type": "MaskLayer" }, { "param": "index", "type": "int" }, { "param": "count", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "masklay", "type": "MaskLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "count", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_mask_clipboard_copy_from_layer
void
void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer) { MaskSpline *spline; /* Nothing to do if selection if disabled for the given layer. */ if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) { return; } mask_clipboard_free_ex(false); if (mask_clipboard.id_hash == NULL) { mask_clipboard.id_hash = BLI_ghash_ptr_new("mask clipboard ID hash"); } for (spline = mask_layer->splines.first; spline; spline = spline->next) { if (spline->flag & SELECT) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); int i; for (i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) { int len = strlen(point->parent.id->name); char *name_copy = MEM_mallocN(len + 1, "mask clipboard ID name"); strcpy(name_copy, point->parent.id->name); BLI_ghash_insert(mask_clipboard.id_hash, point->parent.id, name_copy); } } } BLI_addtail(&mask_clipboard.splines, spline_new); } } }
/* Copy selected visible splines from the given layer to clipboard. */
Copy selected visible splines from the given layer to clipboard.
[ "Copy", "selected", "visible", "splines", "from", "the", "given", "layer", "to", "clipboard", "." ]
void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer) { MaskSpline *spline; if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) { return; } mask_clipboard_free_ex(false); if (mask_clipboard.id_hash == NULL) { mask_clipboard.id_hash = BLI_ghash_ptr_new("mask clipboard ID hash"); } for (spline = mask_layer->splines.first; spline; spline = spline->next) { if (spline->flag & SELECT) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); int i; for (i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) { int len = strlen(point->parent.id->name); char *name_copy = MEM_mallocN(len + 1, "mask clipboard ID name"); strcpy(name_copy, point->parent.id->name); BLI_ghash_insert(mask_clipboard.id_hash, point->parent.id, name_copy); } } } BLI_addtail(&mask_clipboard.splines, spline_new); } } }
[ "void", "BKE_mask_clipboard_copy_from_layer", "(", "MaskLayer", "*", "mask_layer", ")", "{", "MaskSpline", "*", "spline", ";", "if", "(", "mask_layer", "->", "restrictflag", "&", "MASK_RESTRICT_SELECT", ")", "{", "return", ";", "}", "mask_clipboard_free_ex", "(", "false", ")", ";", "if", "(", "mask_clipboard", ".", "id_hash", "==", "NULL", ")", "{", "mask_clipboard", ".", "id_hash", "=", "BLI_ghash_ptr_new", "(", "\"", "\"", ")", ";", "}", "for", "(", "spline", "=", "mask_layer", "->", "splines", ".", "first", ";", "spline", ";", "spline", "=", "spline", "->", "next", ")", "{", "if", "(", "spline", "->", "flag", "&", "SELECT", ")", "{", "MaskSpline", "*", "spline_new", "=", "BKE_mask_spline_copy", "(", "spline", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "spline_new", "->", "tot_point", ";", "i", "++", ")", "{", "MaskSplinePoint", "*", "point", "=", "&", "spline_new", "->", "points", "[", "i", "]", ";", "if", "(", "point", "->", "parent", ".", "id", ")", "{", "if", "(", "!", "BLI_ghash_lookup", "(", "mask_clipboard", ".", "id_hash", ",", "point", "->", "parent", ".", "id", ")", ")", "{", "int", "len", "=", "strlen", "(", "point", "->", "parent", ".", "id", "->", "name", ")", ";", "char", "*", "name_copy", "=", "MEM_mallocN", "(", "len", "+", "1", ",", "\"", "\"", ")", ";", "strcpy", "(", "name_copy", ",", "point", "->", "parent", ".", "id", "->", "name", ")", ";", "BLI_ghash_insert", "(", "mask_clipboard", ".", "id_hash", ",", "point", "->", "parent", ".", "id", ",", "name_copy", ")", ";", "}", "}", "}", "BLI_addtail", "(", "&", "mask_clipboard", ".", "splines", ",", "spline_new", ")", ";", "}", "}", "}" ]
Copy selected visible splines from the given layer to clipboard.
[ "Copy", "selected", "visible", "splines", "from", "the", "given", "layer", "to", "clipboard", "." ]
[ "/* Nothing to do if selection if disabled for the given layer. */" ]
[ { "param": "mask_layer", "type": "MaskLayer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mask_layer", "type": "MaskLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
fc087ff91b23a5aa9167ce65ce406408db24ac63
DemonRem/blender
source/blender/blenkernel/intern/mask.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_mask_clipboard_paste_to_layer
void
void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer) { MaskSpline *spline; for (spline = mask_clipboard.splines.first; spline; spline = spline->next) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); int i; for (i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id); ListBase *listbase; BLI_assert(id_name != NULL); listbase = which_libbase(bmain, GS(id_name)); point->parent.id = BLI_findstring(listbase, id_name + 2, offsetof(ID, name) + 2); } } BLI_addtail(&mask_layer->splines, spline_new); } }
/* Paste the contents of clipboard to given mask layer */
Paste the contents of clipboard to given mask layer
[ "Paste", "the", "contents", "of", "clipboard", "to", "given", "mask", "layer" ]
void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer) { MaskSpline *spline; for (spline = mask_clipboard.splines.first; spline; spline = spline->next) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); int i; for (i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id); ListBase *listbase; BLI_assert(id_name != NULL); listbase = which_libbase(bmain, GS(id_name)); point->parent.id = BLI_findstring(listbase, id_name + 2, offsetof(ID, name) + 2); } } BLI_addtail(&mask_layer->splines, spline_new); } }
[ "void", "BKE_mask_clipboard_paste_to_layer", "(", "Main", "*", "bmain", ",", "MaskLayer", "*", "mask_layer", ")", "{", "MaskSpline", "*", "spline", ";", "for", "(", "spline", "=", "mask_clipboard", ".", "splines", ".", "first", ";", "spline", ";", "spline", "=", "spline", "->", "next", ")", "{", "MaskSpline", "*", "spline_new", "=", "BKE_mask_spline_copy", "(", "spline", ")", ";", "int", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "spline_new", "->", "tot_point", ";", "i", "++", ")", "{", "MaskSplinePoint", "*", "point", "=", "&", "spline_new", "->", "points", "[", "i", "]", ";", "if", "(", "point", "->", "parent", ".", "id", ")", "{", "const", "char", "*", "id_name", "=", "BLI_ghash_lookup", "(", "mask_clipboard", ".", "id_hash", ",", "point", "->", "parent", ".", "id", ")", ";", "ListBase", "*", "listbase", ";", "BLI_assert", "(", "id_name", "!=", "NULL", ")", ";", "listbase", "=", "which_libbase", "(", "bmain", ",", "GS", "(", "id_name", ")", ")", ";", "point", "->", "parent", ".", "id", "=", "BLI_findstring", "(", "listbase", ",", "id_name", "+", "2", ",", "offsetof", "(", "ID", ",", "name", ")", "+", "2", ")", ";", "}", "}", "BLI_addtail", "(", "&", "mask_layer", "->", "splines", ",", "spline_new", ")", ";", "}", "}" ]
Paste the contents of clipboard to given mask layer
[ "Paste", "the", "contents", "of", "clipboard", "to", "given", "mask", "layer" ]
[]
[ { "param": "bmain", "type": "Main" }, { "param": "mask_layer", "type": "MaskLayer" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mask_layer", "type": "MaskLayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
487de27aff28cae491d89bf065d92c078cc81212
DemonRem/blender
source/blender/editors/transform/transform_convert_curve.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
bezt_select_to_transform_triple_flag
int
static int bezt_select_to_transform_triple_flag(const BezTriple *bezt, const bool hide_handles) { int flag = 0; if (hide_handles) { if (bezt->f2 & SELECT) { flag = (1 << 0) | (1 << 1) | (1 << 2); } } else { flag = (((bezt->f1 & SELECT) ? (1 << 0) : 0) | ((bezt->f2 & SELECT) ? (1 << 1) : 0) | ((bezt->f3 & SELECT) ? (1 << 2) : 0)); } /* Special case for auto & aligned handles: * When a center point is being moved without the handles, * leaving the handles stationary makes no sense and only causes strange behavior, * where one handle is arbitrarily anchored, the other one is aligned and lengthened * based on where the center point is moved. Also a bug when cancelling, see: T52007. * * A more 'correct' solution could be to store handle locations in 'TransDataCurveHandleFlags'. * However that doesn't resolve odd behavior, so best transform the handles in this case. */ if ((flag != ((1 << 0) | (1 << 1) | (1 << 2))) && (flag & (1 << 1))) { if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) && ELEM(bezt->h2, HD_AUTO, HD_ALIGN)) { flag = (1 << 0) | (1 << 1) | (1 << 2); } } return flag; }
/** * For the purpose of transform code we need to behave as if handles are selected, * even when they aren't (see special case below). */
For the purpose of transform code we need to behave as if handles are selected, even when they aren't .
[ "For", "the", "purpose", "of", "transform", "code", "we", "need", "to", "behave", "as", "if", "handles", "are", "selected", "even", "when", "they", "aren", "'", "t", "." ]
static int bezt_select_to_transform_triple_flag(const BezTriple *bezt, const bool hide_handles) { int flag = 0; if (hide_handles) { if (bezt->f2 & SELECT) { flag = (1 << 0) | (1 << 1) | (1 << 2); } } else { flag = (((bezt->f1 & SELECT) ? (1 << 0) : 0) | ((bezt->f2 & SELECT) ? (1 << 1) : 0) | ((bezt->f3 & SELECT) ? (1 << 2) : 0)); } if ((flag != ((1 << 0) | (1 << 1) | (1 << 2))) && (flag & (1 << 1))) { if (ELEM(bezt->h1, HD_AUTO, HD_ALIGN) && ELEM(bezt->h2, HD_AUTO, HD_ALIGN)) { flag = (1 << 0) | (1 << 1) | (1 << 2); } } return flag; }
[ "static", "int", "bezt_select_to_transform_triple_flag", "(", "const", "BezTriple", "*", "bezt", ",", "const", "bool", "hide_handles", ")", "{", "int", "flag", "=", "0", ";", "if", "(", "hide_handles", ")", "{", "if", "(", "bezt", "->", "f2", "&", "SELECT", ")", "{", "flag", "=", "(", "1", "<<", "0", ")", "|", "(", "1", "<<", "1", ")", "|", "(", "1", "<<", "2", ")", ";", "}", "}", "else", "{", "flag", "=", "(", "(", "(", "bezt", "->", "f1", "&", "SELECT", ")", "?", "(", "1", "<<", "0", ")", ":", "0", ")", "|", "(", "(", "bezt", "->", "f2", "&", "SELECT", ")", "?", "(", "1", "<<", "1", ")", ":", "0", ")", "|", "(", "(", "bezt", "->", "f3", "&", "SELECT", ")", "?", "(", "1", "<<", "2", ")", ":", "0", ")", ")", ";", "}", "if", "(", "(", "flag", "!=", "(", "(", "1", "<<", "0", ")", "|", "(", "1", "<<", "1", ")", "|", "(", "1", "<<", "2", ")", ")", ")", "&&", "(", "flag", "&", "(", "1", "<<", "1", ")", ")", ")", "{", "if", "(", "ELEM", "(", "bezt", "->", "h1", ",", "HD_AUTO", ",", "HD_ALIGN", ")", "&&", "ELEM", "(", "bezt", "->", "h2", ",", "HD_AUTO", ",", "HD_ALIGN", ")", ")", "{", "flag", "=", "(", "1", "<<", "0", ")", "|", "(", "1", "<<", "1", ")", "|", "(", "1", "<<", "2", ")", ";", "}", "}", "return", "flag", ";", "}" ]
For the purpose of transform code we need to behave as if handles are selected, even when they aren't (see special case below).
[ "For", "the", "purpose", "of", "transform", "code", "we", "need", "to", "behave", "as", "if", "handles", "are", "selected", "even", "when", "they", "aren", "'", "t", "(", "see", "special", "case", "below", ")", "." ]
[ "/* Special case for auto & aligned handles:\n * When a center point is being moved without the handles,\n * leaving the handles stationary makes no sense and only causes strange behavior,\n * where one handle is arbitrarily anchored, the other one is aligned and lengthened\n * based on where the center point is moved. Also a bug when cancelling, see: T52007.\n *\n * A more 'correct' solution could be to store handle locations in 'TransDataCurveHandleFlags'.\n * However that doesn't resolve odd behavior, so best transform the handles in this case.\n */" ]
[ { "param": "bezt", "type": "BezTriple" }, { "param": "hide_handles", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bezt", "type": "BezTriple", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hide_handles", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_free
void
void BKE_collection_free(Collection *collection) { /* No animdata here. */ BKE_previewimg_free(&collection->preview); BLI_freelistN(&collection->gobject); BLI_freelistN(&collection->children); BLI_freelistN(&collection->parents); BKE_collection_object_cache_free(collection); }
/** Free (or release) any data used by this collection (does not free the collection itself). */
Free (or release) any data used by this collection (does not free the collection itself).
[ "Free", "(", "or", "release", ")", "any", "data", "used", "by", "this", "collection", "(", "does", "not", "free", "the", "collection", "itself", ")", "." ]
void BKE_collection_free(Collection *collection) { BKE_previewimg_free(&collection->preview); BLI_freelistN(&collection->gobject); BLI_freelistN(&collection->children); BLI_freelistN(&collection->parents); BKE_collection_object_cache_free(collection); }
[ "void", "BKE_collection_free", "(", "Collection", "*", "collection", ")", "{", "BKE_previewimg_free", "(", "&", "collection", "->", "preview", ")", ";", "BLI_freelistN", "(", "&", "collection", "->", "gobject", ")", ";", "BLI_freelistN", "(", "&", "collection", "->", "children", ")", ";", "BLI_freelistN", "(", "&", "collection", "->", "parents", ")", ";", "BKE_collection_object_cache_free", "(", "collection", ")", ";", "}" ]
Free (or release) any data used by this collection (does not free the collection itself).
[ "Free", "(", "or", "release", ")", "any", "data", "used", "by", "this", "collection", "(", "does", "not", "free", "the", "collection", "itself", ")", "." ]
[ "/* No animdata here. */" ]
[ { "param": "collection", "type": "Collection" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "collection", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_delete
bool
bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) { /* Master collection is not real datablock, can't be removed. */ if (collection->flag & COLLECTION_IS_MASTER) { BLI_assert(!"Scene master collection can't be deleted"); return false; } if (hierarchy) { /* Remove child objects. */ CollectionObject *cob = collection->gobject.first; while (cob != NULL) { collection_object_remove(bmain, collection, cob->ob, true); cob = collection->gobject.first; } /* Delete all child collections recursively. */ CollectionChild *child = collection->children.first; while (child != NULL) { BKE_collection_delete(bmain, child->collection, hierarchy); child = collection->children.first; } } else { /* Link child collections into parent collection. */ for (CollectionChild *child = collection->children.first; child; child = child->next) { for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { Collection *parent = cparent->collection; collection_child_add(parent, child->collection, 0, true); } } CollectionObject *cob = collection->gobject.first; while (cob != NULL) { /* Link child object into parent collections. */ for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { Collection *parent = cparent->collection; collection_object_add(bmain, parent, cob->ob, 0, true); } /* Remove child object. */ collection_object_remove(bmain, collection, cob->ob, true); cob = collection->gobject.first; } } BKE_id_delete(bmain, collection); BKE_main_collection_sync(bmain); return true; }
/** * Remove a collection, optionally removing its child objects or moving * them to parent collections. */
Remove a collection, optionally removing its child objects or moving them to parent collections.
[ "Remove", "a", "collection", "optionally", "removing", "its", "child", "objects", "or", "moving", "them", "to", "parent", "collections", "." ]
bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy) { if (collection->flag & COLLECTION_IS_MASTER) { BLI_assert(!"Scene master collection can't be deleted"); return false; } if (hierarchy) { CollectionObject *cob = collection->gobject.first; while (cob != NULL) { collection_object_remove(bmain, collection, cob->ob, true); cob = collection->gobject.first; } CollectionChild *child = collection->children.first; while (child != NULL) { BKE_collection_delete(bmain, child->collection, hierarchy); child = collection->children.first; } } else { for (CollectionChild *child = collection->children.first; child; child = child->next) { for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { Collection *parent = cparent->collection; collection_child_add(parent, child->collection, 0, true); } } CollectionObject *cob = collection->gobject.first; while (cob != NULL) { for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) { Collection *parent = cparent->collection; collection_object_add(bmain, parent, cob->ob, 0, true); } collection_object_remove(bmain, collection, cob->ob, true); cob = collection->gobject.first; } } BKE_id_delete(bmain, collection); BKE_main_collection_sync(bmain); return true; }
[ "bool", "BKE_collection_delete", "(", "Main", "*", "bmain", ",", "Collection", "*", "collection", ",", "bool", "hierarchy", ")", "{", "if", "(", "collection", "->", "flag", "&", "COLLECTION_IS_MASTER", ")", "{", "BLI_assert", "(", "!", "\"", "\"", ")", ";", "return", "false", ";", "}", "if", "(", "hierarchy", ")", "{", "CollectionObject", "*", "cob", "=", "collection", "->", "gobject", ".", "first", ";", "while", "(", "cob", "!=", "NULL", ")", "{", "collection_object_remove", "(", "bmain", ",", "collection", ",", "cob", "->", "ob", ",", "true", ")", ";", "cob", "=", "collection", "->", "gobject", ".", "first", ";", "}", "CollectionChild", "*", "child", "=", "collection", "->", "children", ".", "first", ";", "while", "(", "child", "!=", "NULL", ")", "{", "BKE_collection_delete", "(", "bmain", ",", "child", "->", "collection", ",", "hierarchy", ")", ";", "child", "=", "collection", "->", "children", ".", "first", ";", "}", "}", "else", "{", "for", "(", "CollectionChild", "*", "child", "=", "collection", "->", "children", ".", "first", ";", "child", ";", "child", "=", "child", "->", "next", ")", "{", "for", "(", "CollectionParent", "*", "cparent", "=", "collection", "->", "parents", ".", "first", ";", "cparent", ";", "cparent", "=", "cparent", "->", "next", ")", "{", "Collection", "*", "parent", "=", "cparent", "->", "collection", ";", "collection_child_add", "(", "parent", ",", "child", "->", "collection", ",", "0", ",", "true", ")", ";", "}", "}", "CollectionObject", "*", "cob", "=", "collection", "->", "gobject", ".", "first", ";", "while", "(", "cob", "!=", "NULL", ")", "{", "for", "(", "CollectionParent", "*", "cparent", "=", "collection", "->", "parents", ".", "first", ";", "cparent", ";", "cparent", "=", "cparent", "->", "next", ")", "{", "Collection", "*", "parent", "=", "cparent", "->", "collection", ";", "collection_object_add", "(", "bmain", ",", "parent", ",", "cob", "->", "ob", ",", "0", ",", "true", ")", ";", "}", "collection_object_remove", "(", "bmain", ",", "collection", ",", "cob", "->", "ob", ",", "true", ")", ";", "cob", "=", "collection", "->", "gobject", ".", "first", ";", "}", "}", "BKE_id_delete", "(", "bmain", ",", "collection", ")", ";", "BKE_main_collection_sync", "(", "bmain", ")", ";", "return", "true", ";", "}" ]
Remove a collection, optionally removing its child objects or moving them to parent collections.
[ "Remove", "a", "collection", "optionally", "removing", "its", "child", "objects", "or", "moving", "them", "to", "parent", "collections", "." ]
[ "/* Master collection is not real datablock, can't be removed. */", "/* Remove child objects. */", "/* Delete all child collections recursively. */", "/* Link child collections into parent collection. */", "/* Link child object into parent collections. */", "/* Remove child object. */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "collection", "type": "Collection" }, { "param": "hierarchy", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "collection", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hierarchy", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_copy_data
void
void BKE_collection_copy_data(Main *bmain, Collection *collection_dst, const Collection *collection_src, const int flag) { BLI_assert(((collection_src->flag & COLLECTION_IS_MASTER) != 0) == ((collection_src->id.flag & LIB_PRIVATE_DATA) != 0)); /* Do not copy collection's preview (same behavior as for objects). */ if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */ BKE_previewimg_id_copy(&collection_dst->id, &collection_src->id); } else { collection_dst->preview = NULL; } collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE; BLI_listbase_clear(&collection_dst->object_cache); BLI_listbase_clear(&collection_dst->gobject); BLI_listbase_clear(&collection_dst->children); BLI_listbase_clear(&collection_dst->parents); for (CollectionChild *child = collection_src->children.first; child; child = child->next) { collection_child_add(collection_dst, child->collection, flag, false); } for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) { collection_object_add(bmain, collection_dst, cob->ob, flag, false); } }
/** * Only copy internal data of Collection ID from source * to already allocated/initialized destination. * You probably never want to use that directly, * use #BKE_id_copy or #BKE_id_copy_ex for typical needs. * * WARNING! This function will not handle ID user count! * * \param flag: Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */
Only copy internal data of Collection ID from source to already allocated/initialized destination. You probably never want to use that directly, use #BKE_id_copy or #BKE_id_copy_ex for typical needs. WARNING. This function will not handle ID user count! \param flag: Copying options .
[ "Only", "copy", "internal", "data", "of", "Collection", "ID", "from", "source", "to", "already", "allocated", "/", "initialized", "destination", ".", "You", "probably", "never", "want", "to", "use", "that", "directly", "use", "#BKE_id_copy", "or", "#BKE_id_copy_ex", "for", "typical", "needs", ".", "WARNING", ".", "This", "function", "will", "not", "handle", "ID", "user", "count!", "\\", "param", "flag", ":", "Copying", "options", "." ]
void BKE_collection_copy_data(Main *bmain, Collection *collection_dst, const Collection *collection_src, const int flag) { BLI_assert(((collection_src->flag & COLLECTION_IS_MASTER) != 0) == ((collection_src->id.flag & LIB_PRIVATE_DATA) != 0)); if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { BKE_previewimg_id_copy(&collection_dst->id, &collection_src->id); } else { collection_dst->preview = NULL; } collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE; BLI_listbase_clear(&collection_dst->object_cache); BLI_listbase_clear(&collection_dst->gobject); BLI_listbase_clear(&collection_dst->children); BLI_listbase_clear(&collection_dst->parents); for (CollectionChild *child = collection_src->children.first; child; child = child->next) { collection_child_add(collection_dst, child->collection, flag, false); } for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) { collection_object_add(bmain, collection_dst, cob->ob, flag, false); } }
[ "void", "BKE_collection_copy_data", "(", "Main", "*", "bmain", ",", "Collection", "*", "collection_dst", ",", "const", "Collection", "*", "collection_src", ",", "const", "int", "flag", ")", "{", "BLI_assert", "(", "(", "(", "collection_src", "->", "flag", "&", "COLLECTION_IS_MASTER", ")", "!=", "0", ")", "==", "(", "(", "collection_src", "->", "id", ".", "flag", "&", "LIB_PRIVATE_DATA", ")", "!=", "0", ")", ")", ";", "if", "(", "(", "flag", "&", "LIB_ID_COPY_NO_PREVIEW", ")", "==", "0", "&&", "false", ")", "{", "BKE_previewimg_id_copy", "(", "&", "collection_dst", "->", "id", ",", "&", "collection_src", "->", "id", ")", ";", "}", "else", "{", "collection_dst", "->", "preview", "=", "NULL", ";", "}", "collection_dst", "->", "flag", "&=", "~", "COLLECTION_HAS_OBJECT_CACHE", ";", "BLI_listbase_clear", "(", "&", "collection_dst", "->", "object_cache", ")", ";", "BLI_listbase_clear", "(", "&", "collection_dst", "->", "gobject", ")", ";", "BLI_listbase_clear", "(", "&", "collection_dst", "->", "children", ")", ";", "BLI_listbase_clear", "(", "&", "collection_dst", "->", "parents", ")", ";", "for", "(", "CollectionChild", "*", "child", "=", "collection_src", "->", "children", ".", "first", ";", "child", ";", "child", "=", "child", "->", "next", ")", "{", "collection_child_add", "(", "collection_dst", ",", "child", "->", "collection", ",", "flag", ",", "false", ")", ";", "}", "for", "(", "CollectionObject", "*", "cob", "=", "collection_src", "->", "gobject", ".", "first", ";", "cob", ";", "cob", "=", "cob", "->", "next", ")", "{", "collection_object_add", "(", "bmain", ",", "collection_dst", ",", "cob", "->", "ob", ",", "flag", ",", "false", ")", ";", "}", "}" ]
Only copy internal data of Collection ID from source to already allocated/initialized destination.
[ "Only", "copy", "internal", "data", "of", "Collection", "ID", "from", "source", "to", "already", "allocated", "/", "initialized", "destination", "." ]
[ "/* Do not copy collection's preview (same behavior as for objects). */", "/* XXX TODO temp hack */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "collection_dst", "type": "Collection" }, { "param": "collection_src", "type": "Collection" }, { "param": "flag", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "collection_dst", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "collection_src", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flag", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_duplicate
Collection
Collection *BKE_collection_duplicate(Main *bmain, Collection *parent, Collection *collection, const bool do_hierarchy, const bool do_objects, const bool do_obdata) { /* It's not allowed to copy the master collection. */ BLI_assert((collection->id.flag & LIB_PRIVATE_DATA) == 0); BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0); if (collection->flag & COLLECTION_IS_MASTER) { return NULL; } if (do_hierarchy) { BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); } Collection *collection_new = collection_duplicate_recursive( bmain, parent, collection, do_hierarchy, do_objects, do_obdata); /* This code will follows into all ID links using an ID tagged with LIB_TAG_NEW.*/ BKE_libblock_relink_to_newid(&collection_new->id); if (do_hierarchy) { /* Cleanup. */ BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); } BKE_main_collection_sync(bmain); return collection_new; }
/** * Make either a shallow copy, or deeper duplicate of given collection. * * If \a do_hierarchy and \a do_deep_copy are false, this is a regular (shallow) ID copy. * * \warning If any 'deep copy' behavior is enabled, * this functions will clear all \a bmain id.idnew pointers. * * \param do_hierarchy: If true, it will recursively make shallow copies of children collections. * \param do_objects: If true, it will also make duplicates of objects. * This one does nothing if \a do_hierarchy is not set. * \param do_obdata: If true, it will also make deep duplicates of objects, * using behavior defined in user settings (#U.dupflag). * This one does nothing if \a do_hierarchy and \a do_objects are not set. */
Make either a shallow copy, or deeper duplicate of given collection. If \a do_hierarchy and \a do_deep_copy are false, this is a regular (shallow) ID copy. \warning If any 'deep copy' behavior is enabled, this functions will clear all \a bmain id.idnew pointers. \param do_hierarchy: If true, it will recursively make shallow copies of children collections. \param do_objects: If true, it will also make duplicates of objects. This one does nothing if \a do_hierarchy is not set. \param do_obdata: If true, it will also make deep duplicates of objects, using behavior defined in user settings (#U.dupflag). This one does nothing if \a do_hierarchy and \a do_objects are not set.
[ "Make", "either", "a", "shallow", "copy", "or", "deeper", "duplicate", "of", "given", "collection", ".", "If", "\\", "a", "do_hierarchy", "and", "\\", "a", "do_deep_copy", "are", "false", "this", "is", "a", "regular", "(", "shallow", ")", "ID", "copy", ".", "\\", "warning", "If", "any", "'", "deep", "copy", "'", "behavior", "is", "enabled", "this", "functions", "will", "clear", "all", "\\", "a", "bmain", "id", ".", "idnew", "pointers", ".", "\\", "param", "do_hierarchy", ":", "If", "true", "it", "will", "recursively", "make", "shallow", "copies", "of", "children", "collections", ".", "\\", "param", "do_objects", ":", "If", "true", "it", "will", "also", "make", "duplicates", "of", "objects", ".", "This", "one", "does", "nothing", "if", "\\", "a", "do_hierarchy", "is", "not", "set", ".", "\\", "param", "do_obdata", ":", "If", "true", "it", "will", "also", "make", "deep", "duplicates", "of", "objects", "using", "behavior", "defined", "in", "user", "settings", "(", "#U", ".", "dupflag", ")", ".", "This", "one", "does", "nothing", "if", "\\", "a", "do_hierarchy", "and", "\\", "a", "do_objects", "are", "not", "set", "." ]
Collection *BKE_collection_duplicate(Main *bmain, Collection *parent, Collection *collection, const bool do_hierarchy, const bool do_objects, const bool do_obdata) { BLI_assert((collection->id.flag & LIB_PRIVATE_DATA) == 0); BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0); if (collection->flag & COLLECTION_IS_MASTER) { return NULL; } if (do_hierarchy) { BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); } Collection *collection_new = collection_duplicate_recursive( bmain, parent, collection, do_hierarchy, do_objects, do_obdata); BKE_libblock_relink_to_newid(&collection_new->id); if (do_hierarchy) { BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); } BKE_main_collection_sync(bmain); return collection_new; }
[ "Collection", "*", "BKE_collection_duplicate", "(", "Main", "*", "bmain", ",", "Collection", "*", "parent", ",", "Collection", "*", "collection", ",", "const", "bool", "do_hierarchy", ",", "const", "bool", "do_objects", ",", "const", "bool", "do_obdata", ")", "{", "BLI_assert", "(", "(", "collection", "->", "id", ".", "flag", "&", "LIB_PRIVATE_DATA", ")", "==", "0", ")", ";", "BLI_assert", "(", "(", "collection", "->", "flag", "&", "COLLECTION_IS_MASTER", ")", "==", "0", ")", ";", "if", "(", "collection", "->", "flag", "&", "COLLECTION_IS_MASTER", ")", "{", "return", "NULL", ";", "}", "if", "(", "do_hierarchy", ")", "{", "BKE_main_id_tag_all", "(", "bmain", ",", "LIB_TAG_NEW", ",", "false", ")", ";", "BKE_main_id_clear_newpoins", "(", "bmain", ")", ";", "}", "Collection", "*", "collection_new", "=", "collection_duplicate_recursive", "(", "bmain", ",", "parent", ",", "collection", ",", "do_hierarchy", ",", "do_objects", ",", "do_obdata", ")", ";", "BKE_libblock_relink_to_newid", "(", "&", "collection_new", "->", "id", ")", ";", "if", "(", "do_hierarchy", ")", "{", "BKE_main_id_tag_all", "(", "bmain", ",", "LIB_TAG_NEW", ",", "false", ")", ";", "BKE_main_id_clear_newpoins", "(", "bmain", ")", ";", "}", "BKE_main_collection_sync", "(", "bmain", ")", ";", "return", "collection_new", ";", "}" ]
Make either a shallow copy, or deeper duplicate of given collection.
[ "Make", "either", "a", "shallow", "copy", "or", "deeper", "duplicate", "of", "given", "collection", "." ]
[ "/* It's not allowed to copy the master collection. */", "/* This code will follows into all ID links using an ID tagged with LIB_TAG_NEW.*/", "/* Cleanup. */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "parent", "type": "Collection" }, { "param": "collection", "type": "Collection" }, { "param": "do_hierarchy", "type": "bool" }, { "param": "do_objects", "type": "bool" }, { "param": "do_obdata", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "collection", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "do_hierarchy", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "do_objects", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "do_obdata", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_object_add_from
void
void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst) { bool is_instantiated = false; FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { if (!ID_IS_LINKED(collection) && BKE_collection_has_object(collection, ob_src)) { collection_object_add(bmain, collection, ob_dst, 0, true); is_instantiated = true; } } FOREACH_SCENE_COLLECTION_END; if (!is_instantiated) { /* In case we could not find any non-linked collections in which instantiate our ob_dst, * fallback to scene's master collection... */ collection_object_add(bmain, scene->master_collection, ob_dst, 0, true); } BKE_main_collection_sync(bmain); }
/** * Add object to all scene collections that reference object is in * (used to copy objects). */
Add object to all scene collections that reference object is in (used to copy objects).
[ "Add", "object", "to", "all", "scene", "collections", "that", "reference", "object", "is", "in", "(", "used", "to", "copy", "objects", ")", "." ]
void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst) { bool is_instantiated = false; FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) { if (!ID_IS_LINKED(collection) && BKE_collection_has_object(collection, ob_src)) { collection_object_add(bmain, collection, ob_dst, 0, true); is_instantiated = true; } } FOREACH_SCENE_COLLECTION_END; if (!is_instantiated) { collection_object_add(bmain, scene->master_collection, ob_dst, 0, true); } BKE_main_collection_sync(bmain); }
[ "void", "BKE_collection_object_add_from", "(", "Main", "*", "bmain", ",", "Scene", "*", "scene", ",", "Object", "*", "ob_src", ",", "Object", "*", "ob_dst", ")", "{", "bool", "is_instantiated", "=", "false", ";", "FOREACH_SCENE_COLLECTION_BEGIN", "(", "scene", ",", "collection", ")", "", "{", "if", "(", "!", "ID_IS_LINKED", "(", "collection", ")", "&&", "BKE_collection_has_object", "(", "collection", ",", "ob_src", ")", ")", "{", "collection_object_add", "(", "bmain", ",", "collection", ",", "ob_dst", ",", "0", ",", "true", ")", ";", "is_instantiated", "=", "true", ";", "}", "}", "FOREACH_SCENE_COLLECTION_END", ";", "if", "(", "!", "is_instantiated", ")", "{", "collection_object_add", "(", "bmain", ",", "scene", "->", "master_collection", ",", "ob_dst", ",", "0", ",", "true", ")", ";", "}", "BKE_main_collection_sync", "(", "bmain", ")", ";", "}" ]
Add object to all scene collections that reference object is in (used to copy objects).
[ "Add", "object", "to", "all", "scene", "collections", "that", "reference", "object", "is", "in", "(", "used", "to", "copy", "objects", ")", "." ]
[ "/* In case we could not find any non-linked collections in which instantiate our ob_dst,\n * fallback to scene's master collection... */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "scene", "type": "Scene" }, { "param": "ob_src", "type": "Object" }, { "param": "ob_dst", "type": "Object" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scene", "type": "Scene", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob_src", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob_dst", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_parent_relations_rebuild
void
void BKE_collection_parent_relations_rebuild(Collection *collection) { for (CollectionChild *child = collection->children.first, *child_next = NULL; child; child = child_next) { child_next = child->next; if (child->collection == NULL || BKE_collection_find_cycle(collection, child->collection)) { BLI_freelinkN(&collection->children, child); } else { CollectionParent *cparent = MEM_callocN(sizeof(CollectionParent), __func__); cparent->collection = collection; BLI_addtail(&child->collection->parents, cparent); } } }
/** * Rebuild parent relationships from child ones, for all children of given \a collection. * * \note Given collection is assumed to already have valid parents. */
Rebuild parent relationships from child ones, for all children of given \a collection. \note Given collection is assumed to already have valid parents.
[ "Rebuild", "parent", "relationships", "from", "child", "ones", "for", "all", "children", "of", "given", "\\", "a", "collection", ".", "\\", "note", "Given", "collection", "is", "assumed", "to", "already", "have", "valid", "parents", "." ]
void BKE_collection_parent_relations_rebuild(Collection *collection) { for (CollectionChild *child = collection->children.first, *child_next = NULL; child; child = child_next) { child_next = child->next; if (child->collection == NULL || BKE_collection_find_cycle(collection, child->collection)) { BLI_freelinkN(&collection->children, child); } else { CollectionParent *cparent = MEM_callocN(sizeof(CollectionParent), __func__); cparent->collection = collection; BLI_addtail(&child->collection->parents, cparent); } } }
[ "void", "BKE_collection_parent_relations_rebuild", "(", "Collection", "*", "collection", ")", "{", "for", "(", "CollectionChild", "*", "child", "=", "collection", "->", "children", ".", "first", ",", "*", "child_next", "=", "NULL", ";", "child", ";", "child", "=", "child_next", ")", "{", "child_next", "=", "child", "->", "next", ";", "if", "(", "child", "->", "collection", "==", "NULL", "||", "BKE_collection_find_cycle", "(", "collection", ",", "child", "->", "collection", ")", ")", "{", "BLI_freelinkN", "(", "&", "collection", "->", "children", ",", "child", ")", ";", "}", "else", "{", "CollectionParent", "*", "cparent", "=", "MEM_callocN", "(", "sizeof", "(", "CollectionParent", ")", ",", "__func__", ")", ";", "cparent", "->", "collection", "=", "collection", ";", "BLI_addtail", "(", "&", "child", "->", "collection", "->", "parents", ",", "cparent", ")", ";", "}", "}", "}" ]
Rebuild parent relationships from child ones, for all children of given \a collection.
[ "Rebuild", "parent", "relationships", "from", "child", "ones", "for", "all", "children", "of", "given", "\\", "a", "collection", "." ]
[]
[ { "param": "collection", "type": "Collection" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "collection", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
68a38c94ff782176dd292376c659593a056b1dd0
DemonRem/blender
source/blender/blenkernel/intern/collection.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_collection_move
bool
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection) { if (collection->flag & COLLECTION_IS_MASTER) { return false; } if (BKE_collection_find_cycle(to_parent, collection)) { return false; } /* Move to new parent collection */ if (from_parent) { collection_child_remove(from_parent, collection); } collection_child_add(to_parent, collection, 0, true); /* Move to specified location under parent. */ if (relative) { CollectionChild *child = collection_find_child(to_parent, collection); CollectionChild *relative_child = collection_find_child(to_parent, relative); if (relative_child) { BLI_remlink(&to_parent->children, child); if (relative_after) { BLI_insertlinkafter(&to_parent->children, relative_child, child); } else { BLI_insertlinkbefore(&to_parent->children, relative_child, child); } BKE_collection_object_cache_free(to_parent); } } /* Make sure we store the flag of the layer collections before we remove and re-create them. * Otherwise they will get lost and everything will be copied from the new parent collection. */ GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); if (layer_collection == NULL) { continue; } BLI_ghash_insert(view_layer_hash, view_layer, POINTER_FROM_INT(layer_collection->flag)); } } /* Create and remove layer collections. */ BKE_main_collection_sync(bmain); /* Restore back the original layer collection flags. */ GHashIterator gh_iter; GHASH_ITER (gh_iter, view_layer_hash) { ViewLayer *view_layer = BLI_ghashIterator_getKey(&gh_iter); LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); if (layer_collection) { /* We treat exclude as a special case. * * If in a different view layer the parent collection was disabled (e.g., background) * and now we moved a new collection to be part of the background this collection should * probably be disabled. * * Note: If we were to also keep the exclude flag we would need to re-sync the collections. */ layer_collection->flag = POINTER_AS_INT(BLI_ghashIterator_getValue(&gh_iter)) | (layer_collection->flag & LAYER_COLLECTION_EXCLUDE); } } BLI_ghash_free(view_layer_hash, NULL, NULL); /* We need to sync it again to pass the correct flags to the collections objects. */ BKE_main_collection_sync(bmain); return true; }
/***************** Collection move (outliner drag & drop) *********************/
Collection move (outliner drag & drop)
[ "Collection", "move", "(", "outliner", "drag", "&", "drop", ")" ]
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection) { if (collection->flag & COLLECTION_IS_MASTER) { return false; } if (BKE_collection_find_cycle(to_parent, collection)) { return false; } if (from_parent) { collection_child_remove(from_parent, collection); } collection_child_add(to_parent, collection, 0, true); if (relative) { CollectionChild *child = collection_find_child(to_parent, collection); CollectionChild *relative_child = collection_find_child(to_parent, relative); if (relative_child) { BLI_remlink(&to_parent->children, child); if (relative_after) { BLI_insertlinkafter(&to_parent->children, relative_child, child); } else { BLI_insertlinkbefore(&to_parent->children, relative_child, child); } BKE_collection_object_cache_free(to_parent); } } GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__); for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { for (ViewLayer *view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) { LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); if (layer_collection == NULL) { continue; } BLI_ghash_insert(view_layer_hash, view_layer, POINTER_FROM_INT(layer_collection->flag)); } } BKE_main_collection_sync(bmain); GHashIterator gh_iter; GHASH_ITER (gh_iter, view_layer_hash) { ViewLayer *view_layer = BLI_ghashIterator_getKey(&gh_iter); LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection( view_layer, collection); if (layer_collection) { layer_collection->flag = POINTER_AS_INT(BLI_ghashIterator_getValue(&gh_iter)) | (layer_collection->flag & LAYER_COLLECTION_EXCLUDE); } } BLI_ghash_free(view_layer_hash, NULL, NULL); BKE_main_collection_sync(bmain); return true; }
[ "bool", "BKE_collection_move", "(", "Main", "*", "bmain", ",", "Collection", "*", "to_parent", ",", "Collection", "*", "from_parent", ",", "Collection", "*", "relative", ",", "bool", "relative_after", ",", "Collection", "*", "collection", ")", "{", "if", "(", "collection", "->", "flag", "&", "COLLECTION_IS_MASTER", ")", "{", "return", "false", ";", "}", "if", "(", "BKE_collection_find_cycle", "(", "to_parent", ",", "collection", ")", ")", "{", "return", "false", ";", "}", "if", "(", "from_parent", ")", "{", "collection_child_remove", "(", "from_parent", ",", "collection", ")", ";", "}", "collection_child_add", "(", "to_parent", ",", "collection", ",", "0", ",", "true", ")", ";", "if", "(", "relative", ")", "{", "CollectionChild", "*", "child", "=", "collection_find_child", "(", "to_parent", ",", "collection", ")", ";", "CollectionChild", "*", "relative_child", "=", "collection_find_child", "(", "to_parent", ",", "relative", ")", ";", "if", "(", "relative_child", ")", "{", "BLI_remlink", "(", "&", "to_parent", "->", "children", ",", "child", ")", ";", "if", "(", "relative_after", ")", "{", "BLI_insertlinkafter", "(", "&", "to_parent", "->", "children", ",", "relative_child", ",", "child", ")", ";", "}", "else", "{", "BLI_insertlinkbefore", "(", "&", "to_parent", "->", "children", ",", "relative_child", ",", "child", ")", ";", "}", "BKE_collection_object_cache_free", "(", "to_parent", ")", ";", "}", "}", "GHash", "*", "view_layer_hash", "=", "BLI_ghash_new", "(", "BLI_ghashutil_ptrhash", ",", "BLI_ghashutil_ptrcmp", ",", "__func__", ")", ";", "for", "(", "Scene", "*", "scene", "=", "bmain", "->", "scenes", ".", "first", ";", "scene", ";", "scene", "=", "scene", "->", "id", ".", "next", ")", "{", "for", "(", "ViewLayer", "*", "view_layer", "=", "scene", "->", "view_layers", ".", "first", ";", "view_layer", ";", "view_layer", "=", "view_layer", "->", "next", ")", "{", "LayerCollection", "*", "layer_collection", "=", "BKE_layer_collection_first_from_scene_collection", "(", "view_layer", ",", "collection", ")", ";", "if", "(", "layer_collection", "==", "NULL", ")", "{", "continue", ";", "}", "BLI_ghash_insert", "(", "view_layer_hash", ",", "view_layer", ",", "POINTER_FROM_INT", "(", "layer_collection", "->", "flag", ")", ")", ";", "}", "}", "BKE_main_collection_sync", "(", "bmain", ")", ";", "GHashIterator", "gh_iter", ";", "GHASH_ITER", "(", "gh_iter", ",", "view_layer_hash", ")", "", "{", "ViewLayer", "*", "view_layer", "=", "BLI_ghashIterator_getKey", "(", "&", "gh_iter", ")", ";", "LayerCollection", "*", "layer_collection", "=", "BKE_layer_collection_first_from_scene_collection", "(", "view_layer", ",", "collection", ")", ";", "if", "(", "layer_collection", ")", "{", "layer_collection", "->", "flag", "=", "POINTER_AS_INT", "(", "BLI_ghashIterator_getValue", "(", "&", "gh_iter", ")", ")", "|", "(", "layer_collection", "->", "flag", "&", "LAYER_COLLECTION_EXCLUDE", ")", ";", "}", "}", "BLI_ghash_free", "(", "view_layer_hash", ",", "NULL", ",", "NULL", ")", ";", "BKE_main_collection_sync", "(", "bmain", ")", ";", "return", "true", ";", "}" ]
Collection move (outliner drag & drop)
[ "Collection", "move", "(", "outliner", "drag", "&", "drop", ")" ]
[ "/* Move to new parent collection */", "/* Move to specified location under parent. */", "/* Make sure we store the flag of the layer collections before we remove and re-create them.\n * Otherwise they will get lost and everything will be copied from the new parent collection. */", "/* Create and remove layer collections. */", "/* Restore back the original layer collection flags. */", "/* We treat exclude as a special case.\n *\n * If in a different view layer the parent collection was disabled (e.g., background)\n * and now we moved a new collection to be part of the background this collection should\n * probably be disabled.\n *\n * Note: If we were to also keep the exclude flag we would need to re-sync the collections.\n */", "/* We need to sync it again to pass the correct flags to the collections objects. */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "to_parent", "type": "Collection" }, { "param": "from_parent", "type": "Collection" }, { "param": "relative", "type": "Collection" }, { "param": "relative_after", "type": "bool" }, { "param": "collection", "type": "Collection" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "to_parent", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "from_parent", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "relative", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "relative_after", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "collection", "type": "Collection", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_poll
bool
static bool gpencil_draw_poll(bContext *C) { /* if is inside grease pencil draw mode cannot use annotations */ Object *obact = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); if ((sa) && (sa->spacetype == SPACE_VIEW3D)) { if ((obact) && (obact->type == OB_GPENCIL) && (obact->mode == OB_MODE_PAINT_GPENCIL)) { CTX_wm_operator_poll_msg_set(C, "Annotation cannot be used in grease pencil draw mode"); return false; } } if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ if (ED_gpencil_data_get_pointers(C, NULL) != NULL) { /* check if Grease Pencil isn't already running */ if (ED_gpencil_session_active() == 0) { return true; } else { CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active"); } } else { CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into"); } } else { CTX_wm_operator_poll_msg_set(C, "Active region not set"); } return false; }
/* check if context is suitable for drawing */
check if context is suitable for drawing
[ "check", "if", "context", "is", "suitable", "for", "drawing" ]
static bool gpencil_draw_poll(bContext *C) { Object *obact = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); if ((sa) && (sa->spacetype == SPACE_VIEW3D)) { if ((obact) && (obact->type == OB_GPENCIL) && (obact->mode == OB_MODE_PAINT_GPENCIL)) { CTX_wm_operator_poll_msg_set(C, "Annotation cannot be used in grease pencil draw mode"); return false; } } if (ED_operator_regionactive(C)) { if (ED_gpencil_data_get_pointers(C, NULL) != NULL) { if (ED_gpencil_session_active() == 0) { return true; } else { CTX_wm_operator_poll_msg_set(C, "Annotation operator is already active"); } } else { CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into"); } } else { CTX_wm_operator_poll_msg_set(C, "Active region not set"); } return false; }
[ "static", "bool", "gpencil_draw_poll", "(", "bContext", "*", "C", ")", "{", "Object", "*", "obact", "=", "CTX_data_active_object", "(", "C", ")", ";", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "if", "(", "(", "sa", ")", "&&", "(", "sa", "->", "spacetype", "==", "SPACE_VIEW3D", ")", ")", "{", "if", "(", "(", "obact", ")", "&&", "(", "obact", "->", "type", "==", "OB_GPENCIL", ")", "&&", "(", "obact", "->", "mode", "==", "OB_MODE_PAINT_GPENCIL", ")", ")", "{", "CTX_wm_operator_poll_msg_set", "(", "C", ",", "\"", "\"", ")", ";", "return", "false", ";", "}", "}", "if", "(", "ED_operator_regionactive", "(", "C", ")", ")", "{", "if", "(", "ED_gpencil_data_get_pointers", "(", "C", ",", "NULL", ")", "!=", "NULL", ")", "{", "if", "(", "ED_gpencil_session_active", "(", ")", "==", "0", ")", "{", "return", "true", ";", "}", "else", "{", "CTX_wm_operator_poll_msg_set", "(", "C", ",", "\"", "\"", ")", ";", "}", "}", "else", "{", "CTX_wm_operator_poll_msg_set", "(", "C", ",", "\"", "\"", ")", ";", "}", "}", "else", "{", "CTX_wm_operator_poll_msg_set", "(", "C", ",", "\"", "\"", ")", ";", "}", "return", "false", ";", "}" ]
check if context is suitable for drawing
[ "check", "if", "context", "is", "suitable", "for", "drawing" ]
[ "/* if is inside grease pencil draw mode cannot use annotations */", "/* check if current context can support GPencil data */", "/* check if Grease Pencil isn't already running */" ]
[ { "param": "C", "type": "bContext" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_get_3d_reference
void
static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { const float *fp = p->scene->cursor.location; /* use 3D-cursor */ copy_v3_v3(vec, fp); }
/* get the reference point for stroke-point conversions */
get the reference point for stroke-point conversions
[ "get", "the", "reference", "point", "for", "stroke", "-", "point", "conversions" ]
static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { const float *fp = p->scene->cursor.location; copy_v3_v3(vec, fp); }
[ "static", "void", "gp_get_3d_reference", "(", "tGPsdata", "*", "p", ",", "float", "vec", "[", "3", "]", ")", "{", "const", "float", "*", "fp", "=", "p", "->", "scene", "->", "cursor", ".", "location", ";", "copy_v3_v3", "(", "vec", ",", "fp", ")", ";", "}" ]
get the reference point for stroke-point conversions
[ "get", "the", "reference", "point", "for", "stroke", "-", "point", "conversions" ]
[ "/* use 3D-cursor */" ]
[ { "param": "p", "type": "tGPsdata" }, { "param": "vec", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vec", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_convertcoords
void
static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth) { bGPdata *gpd = p->gpd; /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { int mval_i[2]; round_v2i_v2fl(mval_i, mval); if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { /* projecting onto 3D-Geometry * - nothing more needs to be done here, since view_autodist_simple() has already done it */ } else { float mval_prj[2]; float rvec[3], dvec[3]; float zfac; /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. In general, this * works OK, but it could of course be improved. * * TODO: * - investigate using nearest point(s) on a previous stroke as * reference point instead or as offset, for easier stroke matching */ gp_get_3d_reference(p, rvec); zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { float mval_f[2]; sub_v2_v2v2(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } else { zero_v3(out); } } } /* 2d - on 'canvas' (assume that p->v2d is set) */ else if ((gpd->runtime.sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) { UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]); mul_v3_m4v3(out, p->imat, out); } /* 2d - relative to screen (viewport area) */ else { if (p->subrect == NULL) { /* normal 3D view */ out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100; out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { /* camera view, use subrect */ out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100; out[1] = ((mval[1] - p->subrect->ymin) / BLI_rctf_size_y(p->subrect)) * 100; } } }
/* convert screen-coordinates to buffer-coordinates */
convert screen-coordinates to buffer-coordinates
[ "convert", "screen", "-", "coordinates", "to", "buffer", "-", "coordinates" ]
static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[3], float *depth) { bGPdata *gpd = p->gpd; if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) { int mval_i[2]; round_v2i_v2fl(mval_i, mval); if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval_i, out, 0, depth))) { } else { float mval_prj[2]; float rvec[3], dvec[3]; float zfac; gp_get_3d_reference(p, rvec); zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { float mval_f[2]; sub_v2_v2v2(mval_f, mval_prj, mval); ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); sub_v3_v3v3(out, rvec, dvec); } else { zero_v3(out); } } } else if ((gpd->runtime.sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) { UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]); mul_v3_m4v3(out, p->imat, out); } else { if (p->subrect == NULL) { out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100; out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { out[0] = ((mval[0] - p->subrect->xmin) / BLI_rctf_size_x(p->subrect)) * 100; out[1] = ((mval[1] - p->subrect->ymin) / BLI_rctf_size_y(p->subrect)) * 100; } } }
[ "static", "void", "gp_stroke_convertcoords", "(", "tGPsdata", "*", "p", ",", "const", "float", "mval", "[", "2", "]", ",", "float", "out", "[", "3", "]", ",", "float", "*", "depth", ")", "{", "bGPdata", "*", "gpd", "=", "p", "->", "gpd", ";", "if", "(", "gpd", "->", "runtime", ".", "sbuffer_sflag", "&", "GP_STROKE_3DSPACE", ")", "{", "int", "mval_i", "[", "2", "]", ";", "round_v2i_v2fl", "(", "mval_i", ",", "mval", ")", ";", "if", "(", "gpencil_project_check", "(", "p", ")", "&&", "(", "ED_view3d_autodist_simple", "(", "p", "->", "ar", ",", "mval_i", ",", "out", ",", "0", ",", "depth", ")", ")", ")", "{", "}", "else", "{", "float", "mval_prj", "[", "2", "]", ";", "float", "rvec", "[", "3", "]", ",", "dvec", "[", "3", "]", ";", "float", "zfac", ";", "gp_get_3d_reference", "(", "p", ",", "rvec", ")", ";", "zfac", "=", "ED_view3d_calc_zfac", "(", "p", "->", "ar", "->", "regiondata", ",", "rvec", ",", "NULL", ")", ";", "if", "(", "ED_view3d_project_float_global", "(", "p", "->", "ar", ",", "rvec", ",", "mval_prj", ",", "V3D_PROJ_TEST_NOP", ")", "==", "V3D_PROJ_RET_OK", ")", "{", "float", "mval_f", "[", "2", "]", ";", "sub_v2_v2v2", "(", "mval_f", ",", "mval_prj", ",", "mval", ")", ";", "ED_view3d_win_to_delta", "(", "p", "->", "ar", ",", "mval_f", ",", "dvec", ",", "zfac", ")", ";", "sub_v3_v3v3", "(", "out", ",", "rvec", ",", "dvec", ")", ";", "}", "else", "{", "zero_v3", "(", "out", ")", ";", "}", "}", "}", "else", "if", "(", "(", "gpd", "->", "runtime", ".", "sbuffer_sflag", "&", "GP_STROKE_2DSPACE", ")", "&&", "(", "p", "->", "v2d", ")", ")", "{", "UI_view2d_region_to_view", "(", "p", "->", "v2d", ",", "mval", "[", "0", "]", ",", "mval", "[", "1", "]", ",", "&", "out", "[", "0", "]", ",", "&", "out", "[", "1", "]", ")", ";", "mul_v3_m4v3", "(", "out", ",", "p", "->", "imat", ",", "out", ")", ";", "}", "else", "{", "if", "(", "p", "->", "subrect", "==", "NULL", ")", "{", "out", "[", "0", "]", "=", "(", "float", ")", "(", "mval", "[", "0", "]", ")", "/", "(", "float", ")", "(", "p", "->", "ar", "->", "winx", ")", "*", "100", ";", "out", "[", "1", "]", "=", "(", "float", ")", "(", "mval", "[", "1", "]", ")", "/", "(", "float", ")", "(", "p", "->", "ar", "->", "winy", ")", "*", "100", ";", "}", "else", "{", "out", "[", "0", "]", "=", "(", "(", "mval", "[", "0", "]", "-", "p", "->", "subrect", "->", "xmin", ")", "/", "BLI_rctf_size_x", "(", "p", "->", "subrect", ")", ")", "*", "100", ";", "out", "[", "1", "]", "=", "(", "(", "mval", "[", "1", "]", "-", "p", "->", "subrect", "->", "ymin", ")", "/", "BLI_rctf_size_y", "(", "p", "->", "subrect", ")", ")", "*", "100", ";", "}", "}", "}" ]
convert screen-coordinates to buffer-coordinates
[ "convert", "screen", "-", "coordinates", "to", "buffer", "-", "coordinates" ]
[ "/* in 3d-space - pt->x/y/z are 3 side-by-side floats */", "/* projecting onto 3D-Geometry\n * - nothing more needs to be done here, since view_autodist_simple() has already done it\n */", "/* Current method just converts each point in screen-coordinates to\n * 3D-coordinates using the 3D-cursor as reference. In general, this\n * works OK, but it could of course be improved.\n *\n * TODO:\n * - investigate using nearest point(s) on a previous stroke as\n * reference point instead or as offset, for easier stroke matching\n */", "/* 2d - on 'canvas' (assume that p->v2d is set) */", "/* 2d - relative to screen (viewport area) */", "/* normal 3D view */", "/* camera view, use subrect */" ]
[ { "param": "p", "type": "tGPsdata" }, { "param": "mval", "type": "float" }, { "param": "out", "type": "float" }, { "param": "depth", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mval", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "depth", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_addpoint
null
static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; tGPspoint *pt; ToolSettings *ts = p->scene->toolsettings; /* check painting mode */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only - i.e. only store start and end point in buffer */ if (gpd->runtime.sbuffer_used == 0) { /* first point in buffer (start point) */ pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ copy_v2_v2(&pt->x, mval); /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); /* increment buffer size */ gpd->runtime.sbuffer_used++; } else { /* just reset the endpoint to the latest value * - assume that pointers for this are always valid... */ pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1); /* store settings */ copy_v2_v2(&pt->x, mval); /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); /* now the buffer has 2 points (and shouldn't be allowed to get any larger) */ gpd->runtime.sbuffer_used = 2; } /* can keep carrying on this way :) */ return GP_STROKEADD_NORMAL; } else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */ /* check if still room in buffer or add more */ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure( gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false); /* get pointer to destination point */ pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used); /* store settings */ copy_v2_v2(&pt->x, mval); pt->pressure = pressure; /* unused for annotations, but initialise for easier conversions to GP Object */ pt->strength = 1.0f; /* point time */ pt->time = (float)(curtime - p->inittime); /* increment counters */ gpd->runtime.sbuffer_used++; /* smooth while drawing previous points with a reduction factor for previous */ for (int s = 0; s < 3; s++) { gp_smooth_buffer(p, 0.5f * ((3.0f - s) / 3.0f), gpd->runtime.sbuffer_used - s); } return GP_STROKEADD_NORMAL; } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* get pointer to destination point */ pt = (tGPspoint *)(gpd->runtime.sbuffer); /* store settings */ copy_v2_v2(&pt->x, mval); /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, e.g.) */ if (gp_stroke_added_check(p)) { bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->runtime.sbuffer_used == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } pts = &gps->points[gps->totpoints - 1]; /* special case for poly lines: normally, * depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, * so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); /* copy pressure and time */ pts->pressure = pt->pressure; pts->strength = pt->strength; pts->time = pt->time; /* force fill recalc */ gps->flag |= GP_STROKE_RECALC_GEOMETRY; } /* increment counters */ if (gpd->runtime.sbuffer_used == 0) { gpd->runtime.sbuffer_used++; } return GP_STROKEADD_NORMAL; } /* return invalid state for now... */ return GP_STROKEADD_INVALID; }
/* add current stroke-point to buffer (returns whether point was successfully added) */
add current stroke-point to buffer (returns whether point was successfully added)
[ "add", "current", "stroke", "-", "point", "to", "buffer", "(", "returns", "whether", "point", "was", "successfully", "added", ")" ]
static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure, double curtime) { bGPdata *gpd = p->gpd; tGPspoint *pt; ToolSettings *ts = p->scene->toolsettings; if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { if (gpd->runtime.sbuffer_used == 0) { pt = (tGPspoint *)(gpd->runtime.sbuffer); copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); gpd->runtime.sbuffer_used++; } else { pt = ((tGPspoint *)(gpd->runtime.sbuffer) + 1); copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); gpd->runtime.sbuffer_used = 2; } return GP_STROKEADD_NORMAL; } else if (p->paintmode == GP_PAINTMODE_DRAW) { gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure( gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false); pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used); copy_v2_v2(&pt->x, mval); pt->pressure = pressure; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); gpd->runtime.sbuffer_used++; for (int s = 0; s < 3; s++) { gp_smooth_buffer(p, 0.5f * ((3.0f - s) / 3.0f), gpd->runtime.sbuffer_used - s); } return GP_STROKEADD_NORMAL; } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { pt = (tGPspoint *)(gpd->runtime.sbuffer); copy_v2_v2(&pt->x, mval); pt->pressure = 1.0f; pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); if (gp_stroke_added_check(p)) { bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; if (gpd->runtime.sbuffer_used == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } pts = &gps->points[gps->totpoints - 1]; if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); pts->pressure = pt->pressure; pts->strength = pt->strength; pts->time = pt->time; gps->flag |= GP_STROKE_RECALC_GEOMETRY; } if (gpd->runtime.sbuffer_used == 0) { gpd->runtime.sbuffer_used++; } return GP_STROKEADD_NORMAL; } return GP_STROKEADD_INVALID; }
[ "static", "short", "gp_stroke_addpoint", "(", "tGPsdata", "*", "p", ",", "const", "float", "mval", "[", "2", "]", ",", "float", "pressure", ",", "double", "curtime", ")", "{", "bGPdata", "*", "gpd", "=", "p", "->", "gpd", ";", "tGPspoint", "*", "pt", ";", "ToolSettings", "*", "ts", "=", "p", "->", "scene", "->", "toolsettings", ";", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_STRAIGHT", ")", "{", "if", "(", "gpd", "->", "runtime", ".", "sbuffer_used", "==", "0", ")", "{", "pt", "=", "(", "tGPspoint", "*", ")", "(", "gpd", "->", "runtime", ".", "sbuffer", ")", ";", "copy_v2_v2", "(", "&", "pt", "->", "x", ",", "mval", ")", ";", "pt", "->", "pressure", "=", "1.0f", ";", "pt", "->", "strength", "=", "1.0f", ";", "pt", "->", "time", "=", "(", "float", ")", "(", "curtime", "-", "p", "->", "inittime", ")", ";", "gpd", "->", "runtime", ".", "sbuffer_used", "++", ";", "}", "else", "{", "pt", "=", "(", "(", "tGPspoint", "*", ")", "(", "gpd", "->", "runtime", ".", "sbuffer", ")", "+", "1", ")", ";", "copy_v2_v2", "(", "&", "pt", "->", "x", ",", "mval", ")", ";", "pt", "->", "pressure", "=", "1.0f", ";", "pt", "->", "strength", "=", "1.0f", ";", "pt", "->", "time", "=", "(", "float", ")", "(", "curtime", "-", "p", "->", "inittime", ")", ";", "gpd", "->", "runtime", ".", "sbuffer_used", "=", "2", ";", "}", "return", "GP_STROKEADD_NORMAL", ";", "}", "else", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW", ")", "{", "gpd", "->", "runtime", ".", "sbuffer", "=", "ED_gpencil_sbuffer_ensure", "(", "gpd", "->", "runtime", ".", "sbuffer", ",", "&", "gpd", "->", "runtime", ".", "sbuffer_size", ",", "&", "gpd", "->", "runtime", ".", "sbuffer_used", ",", "false", ")", ";", "pt", "=", "(", "(", "tGPspoint", "*", ")", "(", "gpd", "->", "runtime", ".", "sbuffer", ")", "+", "gpd", "->", "runtime", ".", "sbuffer_used", ")", ";", "copy_v2_v2", "(", "&", "pt", "->", "x", ",", "mval", ")", ";", "pt", "->", "pressure", "=", "pressure", ";", "pt", "->", "strength", "=", "1.0f", ";", "pt", "->", "time", "=", "(", "float", ")", "(", "curtime", "-", "p", "->", "inittime", ")", ";", "gpd", "->", "runtime", ".", "sbuffer_used", "++", ";", "for", "(", "int", "s", "=", "0", ";", "s", "<", "3", ";", "s", "++", ")", "{", "gp_smooth_buffer", "(", "p", ",", "0.5f", "*", "(", "(", "3.0f", "-", "s", ")", "/", "3.0f", ")", ",", "gpd", "->", "runtime", ".", "sbuffer_used", "-", "s", ")", ";", "}", "return", "GP_STROKEADD_NORMAL", ";", "}", "else", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_POLY", ")", "{", "pt", "=", "(", "tGPspoint", "*", ")", "(", "gpd", "->", "runtime", ".", "sbuffer", ")", ";", "copy_v2_v2", "(", "&", "pt", "->", "x", ",", "mval", ")", ";", "pt", "->", "pressure", "=", "1.0f", ";", "pt", "->", "strength", "=", "1.0f", ";", "pt", "->", "time", "=", "(", "float", ")", "(", "curtime", "-", "p", "->", "inittime", ")", ";", "if", "(", "gp_stroke_added_check", "(", "p", ")", ")", "{", "bGPDstroke", "*", "gps", "=", "p", "->", "gpf", "->", "strokes", ".", "last", ";", "bGPDspoint", "*", "pts", ";", "if", "(", "gpd", "->", "runtime", ".", "sbuffer_used", "==", "0", ")", "{", "gps", "->", "points", "=", "MEM_reallocN", "(", "gps", "->", "points", ",", "sizeof", "(", "bGPDspoint", ")", "*", "(", "gps", "->", "totpoints", "+", "1", ")", ")", ";", "gps", "->", "totpoints", "++", ";", "}", "pts", "=", "&", "gps", "->", "points", "[", "gps", "->", "totpoints", "-", "1", "]", ";", "if", "(", "gpencil_project_check", "(", "p", ")", ")", "{", "View3D", "*", "v3d", "=", "p", "->", "sa", "->", "spacedata", ".", "first", ";", "view3d_region_operator_needs_opengl", "(", "p", "->", "win", ",", "p", "->", "ar", ")", ";", "ED_view3d_autodist_init", "(", "p", "->", "depsgraph", ",", "p", "->", "ar", ",", "v3d", ",", "(", "ts", "->", "annotate_v3d_align", "&", "GP_PROJECT_DEPTH_STROKE", ")", "?", "1", ":", "0", ")", ";", "}", "gp_stroke_convertcoords", "(", "p", ",", "&", "pt", "->", "x", ",", "&", "pts", "->", "x", ",", "NULL", ")", ";", "pts", "->", "pressure", "=", "pt", "->", "pressure", ";", "pts", "->", "strength", "=", "pt", "->", "strength", ";", "pts", "->", "time", "=", "pt", "->", "time", ";", "gps", "->", "flag", "|=", "GP_STROKE_RECALC_GEOMETRY", ";", "}", "if", "(", "gpd", "->", "runtime", ".", "sbuffer_used", "==", "0", ")", "{", "gpd", "->", "runtime", ".", "sbuffer_used", "++", ";", "}", "return", "GP_STROKEADD_NORMAL", ";", "}", "return", "GP_STROKEADD_INVALID", ";", "}" ]
add current stroke-point to buffer (returns whether point was successfully added)
[ "add", "current", "stroke", "-", "point", "to", "buffer", "(", "returns", "whether", "point", "was", "successfully", "added", ")" ]
[ "/* check painting mode */", "/* straight lines only - i.e. only store start and end point in buffer */", "/* first point in buffer (start point) */", "/* store settings */", "/* T44932 - Pressure vals are unreliable, so ignore for now */", "/* increment buffer size */", "/* just reset the endpoint to the latest value\n * - assume that pointers for this are always valid...\n */", "/* store settings */", "/* T44932 - Pressure vals are unreliable, so ignore for now */", "/* now the buffer has 2 points (and shouldn't be allowed to get any larger) */", "/* can keep carrying on this way :) */", "/* normal drawing */", "/* check if still room in buffer or add more */", "/* get pointer to destination point */", "/* store settings */", "/* unused for annotations, but initialise for easier conversions to GP Object */", "/* point time */", "/* increment counters */", "/* smooth while drawing previous points with a reduction factor for previous */", "/* get pointer to destination point */", "/* store settings */", "/* T44932 - Pressure vals are unreliable, so ignore for now */", "/* if there's stroke for this poly line session add (or replace last) point\n * to stroke. This allows to draw lines more interactively (see new segment\n * during mouse slide, e.g.)\n */", "/* first time point is adding to temporary buffer -- need to allocate new point in stroke */", "/* special case for poly lines: normally,\n * depth is needed only when creating new stroke from buffer,\n * but poly lines are converting to stroke instantly,\n * so initialize depth buffer before converting coordinates\n */", "/* convert screen-coordinates to appropriate coordinates (and store them) */", "/* copy pressure and time */", "/* force fill recalc */", "/* increment counters */", "/* return invalid state for now... */" ]
[ { "param": "p", "type": "tGPsdata" }, { "param": "mval", "type": "float" }, { "param": "pressure", "type": "float" }, { "param": "curtime", "type": "double" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mval", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pressure", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "curtime", "type": "double", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_newfrombuffer
void
static void gp_stroke_newfrombuffer(tGPsdata *p) { bGPdata *gpd = p->gpd; bGPDlayer *gpl = p->gpl; bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; ToolSettings *ts = p->scene->toolsettings; int i, totelem; /* Since strokes are so fine, when using their depth we need a margin * otherwise they might get missed. */ int depth_margin = (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0; /* get total number of points to allocate space for * - drawing straight-lines only requires the endpoints */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { totelem = (gpd->runtime.sbuffer_used >= 2) ? 2 : gpd->runtime.sbuffer_used; } else { totelem = gpd->runtime.sbuffer_used; } /* exit with error if no valid points from this stroke */ if (totelem == 0) { if (G.debug & G_DEBUG) { printf("Error: No valid points in stroke buffer to convert (tot=%d)\n", gpd->runtime.sbuffer_used); } return; } /* special case for poly line -- for already added stroke during session * coordinates are getting added to stroke immediately to allow more * interactive behavior */ if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { if (gp_stroke_added_check(p)) { return; } } /* allocate memory for a new stroke */ gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); /* copy appropriate settings for stroke */ gps->totpoints = totelem; gps->thickness = gpl->thickness; gps->gradient_f = 1.0f; gps->gradient_s[0] = 1.0f; gps->gradient_s[1] = 1.0f; gps->flag = gpd->runtime.sbuffer_sflag; gps->inittime = p->inittime; /* enable recalculation flag by default (only used if hq fill) */ gps->flag |= GP_STROKE_RECALC_GEOMETRY; /* allocate enough memory for a continuous array for storage points */ gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); gps->tot_triangles = 0; /* set pointer to first non-initialized point */ pt = gps->points + (gps->totpoints - totelem); /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only -> only endpoints */ { /* first point */ ptc = gpd->runtime.sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; pt++; } if (totelem == 2) { /* last point if applicable */ ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_used - 1); /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; } } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ ptc = gpd->runtime.sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; pt->time = ptc->time; } else { float *depth_arr = NULL; /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { int mval_i[2], mval_prev[2] = {0}; int interp_depth = 0; int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_used, "depth_points"); for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) { round_v2i_v2fl(mval_i, &ptc->x); if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } else { found_depth = true; } copy_v2_v2_int(mval_prev, mval_i); } if (found_depth == false) { /* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */ for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) { depth_arr[i] = 0.9999f; } } else { if (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) { /* remove all info between the valid endpoints */ int first_valid = 0; int last_valid = 0; for (i = 0; i < gpd->runtime.sbuffer_used; i++) { if (depth_arr[i] != FLT_MAX) { break; } } first_valid = i; for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) { if (depth_arr[i] != FLT_MAX) { break; } } last_valid = i; /* invalidate non-endpoints, so only blend between first and last */ for (i = first_valid + 1; i < last_valid; i++) { depth_arr[i] = FLT_MAX; } interp_depth = true; } if (interp_depth) { interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX); } } } pt = gps->points; /* convert all points (normal behavior) */ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL); /* copy pressure and time */ pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; } if (depth_arr) { MEM_freeN(depth_arr); } } /* add stroke to frame */ BLI_addtail(&p->gpf->strokes, gps); gp_stroke_added_enable(p); }
/* make a new stroke from the buffer data */
make a new stroke from the buffer data
[ "make", "a", "new", "stroke", "from", "the", "buffer", "data" ]
static void gp_stroke_newfrombuffer(tGPsdata *p) { bGPdata *gpd = p->gpd; bGPDlayer *gpl = p->gpl; bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; ToolSettings *ts = p->scene->toolsettings; int i, totelem; int depth_margin = (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0; if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { totelem = (gpd->runtime.sbuffer_used >= 2) ? 2 : gpd->runtime.sbuffer_used; } else { totelem = gpd->runtime.sbuffer_used; } if (totelem == 0) { if (G.debug & G_DEBUG) { printf("Error: No valid points in stroke buffer to convert (tot=%d)\n", gpd->runtime.sbuffer_used); } return; } if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { if (gp_stroke_added_check(p)) { return; } } gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); gps->totpoints = totelem; gps->thickness = gpl->thickness; gps->gradient_f = 1.0f; gps->gradient_s[0] = 1.0f; gps->gradient_s[1] = 1.0f; gps->flag = gpd->runtime.sbuffer_sflag; gps->inittime = p->inittime; gps->flag |= GP_STROKE_RECALC_GEOMETRY; gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); gps->tot_triangles = 0; pt = gps->points + (gps->totpoints - totelem); if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { { ptc = gpd->runtime.sbuffer; gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; pt++; } if (totelem == 2) { ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_used - 1); gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; } } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { ptc = gpd->runtime.sbuffer; gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); pt->pressure = ptc->pressure; pt->strength = ptc->strength; pt->time = ptc->time; } else { float *depth_arr = NULL; if (gpencil_project_check(p)) { int mval_i[2], mval_prev[2] = {0}; int interp_depth = 0; int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_used, "depth_points"); for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) { round_v2i_v2fl(mval_i, &ptc->x); if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( p->ar, mval_i, mval_prev, depth_margin + 1, depth_arr + i) == 0))) { interp_depth = true; } else { found_depth = true; } copy_v2_v2_int(mval_prev, mval_i); } if (found_depth == false) { for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) { depth_arr[i] = 0.9999f; } } else { if (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE_ENDPOINTS) { int first_valid = 0; int last_valid = 0; for (i = 0; i < gpd->runtime.sbuffer_used; i++) { if (depth_arr[i] != FLT_MAX) { break; } } first_valid = i; for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) { if (depth_arr[i] != FLT_MAX) { break; } } last_valid = i; for (i = first_valid + 1; i < last_valid; i++) { depth_arr[i] = FLT_MAX; } interp_depth = true; } if (interp_depth) { interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX); } } } pt = gps->points; for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; i++, ptc++, pt++) { gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL); pt->pressure = ptc->pressure; pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; } if (depth_arr) { MEM_freeN(depth_arr); } } BLI_addtail(&p->gpf->strokes, gps); gp_stroke_added_enable(p); }
[ "static", "void", "gp_stroke_newfrombuffer", "(", "tGPsdata", "*", "p", ")", "{", "bGPdata", "*", "gpd", "=", "p", "->", "gpd", ";", "bGPDlayer", "*", "gpl", "=", "p", "->", "gpl", ";", "bGPDstroke", "*", "gps", ";", "bGPDspoint", "*", "pt", ";", "tGPspoint", "*", "ptc", ";", "ToolSettings", "*", "ts", "=", "p", "->", "scene", "->", "toolsettings", ";", "int", "i", ",", "totelem", ";", "int", "depth_margin", "=", "(", "ts", "->", "annotate_v3d_align", "&", "GP_PROJECT_DEPTH_STROKE", ")", "?", "4", ":", "0", ";", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_STRAIGHT", ")", "{", "totelem", "=", "(", "gpd", "->", "runtime", ".", "sbuffer_used", ">=", "2", ")", "?", "2", ":", "gpd", "->", "runtime", ".", "sbuffer_used", ";", "}", "else", "{", "totelem", "=", "gpd", "->", "runtime", ".", "sbuffer_used", ";", "}", "if", "(", "totelem", "==", "0", ")", "{", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ",", "gpd", "->", "runtime", ".", "sbuffer_used", ")", ";", "}", "return", ";", "}", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_POLY", ")", "{", "if", "(", "gp_stroke_added_check", "(", "p", ")", ")", "{", "return", ";", "}", "}", "gps", "=", "MEM_callocN", "(", "sizeof", "(", "bGPDstroke", ")", ",", "\"", "\"", ")", ";", "gps", "->", "totpoints", "=", "totelem", ";", "gps", "->", "thickness", "=", "gpl", "->", "thickness", ";", "gps", "->", "gradient_f", "=", "1.0f", ";", "gps", "->", "gradient_s", "[", "0", "]", "=", "1.0f", ";", "gps", "->", "gradient_s", "[", "1", "]", "=", "1.0f", ";", "gps", "->", "flag", "=", "gpd", "->", "runtime", ".", "sbuffer_sflag", ";", "gps", "->", "inittime", "=", "p", "->", "inittime", ";", "gps", "->", "flag", "|=", "GP_STROKE_RECALC_GEOMETRY", ";", "gps", "->", "points", "=", "MEM_callocN", "(", "sizeof", "(", "bGPDspoint", ")", "*", "gps", "->", "totpoints", ",", "\"", "\"", ")", ";", "gps", "->", "tot_triangles", "=", "0", ";", "pt", "=", "gps", "->", "points", "+", "(", "gps", "->", "totpoints", "-", "totelem", ")", ";", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_STRAIGHT", ")", "{", "{", "ptc", "=", "gpd", "->", "runtime", ".", "sbuffer", ";", "gp_stroke_convertcoords", "(", "p", ",", "&", "ptc", "->", "x", ",", "&", "pt", "->", "x", ",", "NULL", ")", ";", "pt", "->", "pressure", "=", "ptc", "->", "pressure", ";", "pt", "->", "strength", "=", "ptc", "->", "strength", ";", "CLAMP", "(", "pt", "->", "strength", ",", "GPENCIL_STRENGTH_MIN", ",", "1.0f", ")", ";", "pt", "->", "time", "=", "ptc", "->", "time", ";", "pt", "++", ";", "}", "if", "(", "totelem", "==", "2", ")", "{", "ptc", "=", "(", "(", "tGPspoint", "*", ")", "gpd", "->", "runtime", ".", "sbuffer", ")", "+", "(", "gpd", "->", "runtime", ".", "sbuffer_used", "-", "1", ")", ";", "gp_stroke_convertcoords", "(", "p", ",", "&", "ptc", "->", "x", ",", "&", "pt", "->", "x", ",", "NULL", ")", ";", "pt", "->", "pressure", "=", "ptc", "->", "pressure", ";", "pt", "->", "strength", "=", "ptc", "->", "strength", ";", "CLAMP", "(", "pt", "->", "strength", ",", "GPENCIL_STRENGTH_MIN", ",", "1.0f", ")", ";", "pt", "->", "time", "=", "ptc", "->", "time", ";", "}", "}", "else", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_DRAW_POLY", ")", "{", "ptc", "=", "gpd", "->", "runtime", ".", "sbuffer", ";", "gp_stroke_convertcoords", "(", "p", ",", "&", "ptc", "->", "x", ",", "&", "pt", "->", "x", ",", "NULL", ")", ";", "pt", "->", "pressure", "=", "ptc", "->", "pressure", ";", "pt", "->", "strength", "=", "ptc", "->", "strength", ";", "pt", "->", "time", "=", "ptc", "->", "time", ";", "}", "else", "{", "float", "*", "depth_arr", "=", "NULL", ";", "if", "(", "gpencil_project_check", "(", "p", ")", ")", "{", "int", "mval_i", "[", "2", "]", ",", "mval_prev", "[", "2", "]", "=", "{", "0", "}", ";", "int", "interp_depth", "=", "0", ";", "int", "found_depth", "=", "0", ";", "depth_arr", "=", "MEM_mallocN", "(", "sizeof", "(", "float", ")", "*", "gpd", "->", "runtime", ".", "sbuffer_used", ",", "\"", "\"", ")", ";", "for", "(", "i", "=", "0", ",", "ptc", "=", "gpd", "->", "runtime", ".", "sbuffer", ";", "i", "<", "gpd", "->", "runtime", ".", "sbuffer_used", ";", "i", "++", ",", "ptc", "++", ",", "pt", "++", ")", "{", "round_v2i_v2fl", "(", "mval_i", ",", "&", "ptc", "->", "x", ")", ";", "if", "(", "(", "ED_view3d_autodist_depth", "(", "p", "->", "ar", ",", "mval_i", ",", "depth_margin", ",", "depth_arr", "+", "i", ")", "==", "0", ")", "&&", "(", "i", "&&", "(", "ED_view3d_autodist_depth_seg", "(", "p", "->", "ar", ",", "mval_i", ",", "mval_prev", ",", "depth_margin", "+", "1", ",", "depth_arr", "+", "i", ")", "==", "0", ")", ")", ")", "{", "interp_depth", "=", "true", ";", "}", "else", "{", "found_depth", "=", "true", ";", "}", "copy_v2_v2_int", "(", "mval_prev", ",", "mval_i", ")", ";", "}", "if", "(", "found_depth", "==", "false", ")", "{", "for", "(", "i", "=", "gpd", "->", "runtime", ".", "sbuffer_used", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "depth_arr", "[", "i", "]", "=", "0.9999f", ";", "}", "}", "else", "{", "if", "(", "ts", "->", "annotate_v3d_align", "&", "GP_PROJECT_DEPTH_STROKE_ENDPOINTS", ")", "{", "int", "first_valid", "=", "0", ";", "int", "last_valid", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "gpd", "->", "runtime", ".", "sbuffer_used", ";", "i", "++", ")", "{", "if", "(", "depth_arr", "[", "i", "]", "!=", "FLT_MAX", ")", "{", "break", ";", "}", "}", "first_valid", "=", "i", ";", "for", "(", "i", "=", "gpd", "->", "runtime", ".", "sbuffer_used", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "if", "(", "depth_arr", "[", "i", "]", "!=", "FLT_MAX", ")", "{", "break", ";", "}", "}", "last_valid", "=", "i", ";", "for", "(", "i", "=", "first_valid", "+", "1", ";", "i", "<", "last_valid", ";", "i", "++", ")", "{", "depth_arr", "[", "i", "]", "=", "FLT_MAX", ";", "}", "interp_depth", "=", "true", ";", "}", "if", "(", "interp_depth", ")", "{", "interp_sparse_array", "(", "depth_arr", ",", "gpd", "->", "runtime", ".", "sbuffer_used", ",", "FLT_MAX", ")", ";", "}", "}", "}", "pt", "=", "gps", "->", "points", ";", "for", "(", "i", "=", "0", ",", "ptc", "=", "gpd", "->", "runtime", ".", "sbuffer", ";", "i", "<", "gpd", "->", "runtime", ".", "sbuffer_used", "&&", "ptc", ";", "i", "++", ",", "ptc", "++", ",", "pt", "++", ")", "{", "gp_stroke_convertcoords", "(", "p", ",", "&", "ptc", "->", "x", ",", "&", "pt", "->", "x", ",", "depth_arr", "?", "depth_arr", "+", "i", ":", "NULL", ")", ";", "pt", "->", "pressure", "=", "ptc", "->", "pressure", ";", "pt", "->", "strength", "=", "ptc", "->", "strength", ";", "CLAMP", "(", "pt", "->", "strength", ",", "GPENCIL_STRENGTH_MIN", ",", "1.0f", ")", ";", "pt", "->", "time", "=", "ptc", "->", "time", ";", "}", "if", "(", "depth_arr", ")", "{", "MEM_freeN", "(", "depth_arr", ")", ";", "}", "}", "BLI_addtail", "(", "&", "p", "->", "gpf", "->", "strokes", ",", "gps", ")", ";", "gp_stroke_added_enable", "(", "p", ")", ";", "}" ]
make a new stroke from the buffer data
[ "make", "a", "new", "stroke", "from", "the", "buffer", "data" ]
[ "/* Since strokes are so fine, when using their depth we need a margin\n * otherwise they might get missed. */", "/* get total number of points to allocate space for\n * - drawing straight-lines only requires the endpoints\n */", "/* exit with error if no valid points from this stroke */", "/* special case for poly line -- for already added stroke during session\n * coordinates are getting added to stroke immediately to allow more\n * interactive behavior\n */", "/* allocate memory for a new stroke */", "/* copy appropriate settings for stroke */", "/* enable recalculation flag by default (only used if hq fill) */", "/* allocate enough memory for a continuous array for storage points */", "/* set pointer to first non-initialized point */", "/* copy points from the buffer to the stroke */", "/* straight lines only -> only endpoints */", "/* first point */", "/* convert screen-coordinates to appropriate coordinates (and store them) */", "/* copy pressure and time */", "/* last point if applicable */", "/* convert screen-coordinates to appropriate coordinates (and store them) */", "/* copy pressure and time */", "/* first point */", "/* convert screen-coordinates to appropriate coordinates (and store them) */", "/* copy pressure and time */", "/* get an array of depths, far depths are blended */", "/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */", "/* remove all info between the valid endpoints */", "/* invalidate non-endpoints, so only blend between first and last */", "/* convert all points (normal behavior) */", "/* convert screen-coordinates to appropriate coordinates (and store them) */", "/* copy pressure and time */", "/* add stroke to frame */" ]
[ { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_free_stroke
void
static void gp_free_stroke(bGPDframe *gpf, bGPDstroke *gps) { if (gps->points) { MEM_freeN(gps->points); } if (gps->dvert) { BKE_gpencil_free_stroke_weights(gps); MEM_freeN(gps->dvert); } if (gps->triangles) { MEM_freeN(gps->triangles); } BLI_freelinkN(&gpf->strokes, gps); }
/* helper to free a stroke * NOTE: gps->dvert and gps->triangles should be NULL, but check anyway for good measure */
helper to free a stroke NOTE: gps->dvert and gps->triangles should be NULL, but check anyway for good measure
[ "helper", "to", "free", "a", "stroke", "NOTE", ":", "gps", "-", ">", "dvert", "and", "gps", "-", ">", "triangles", "should", "be", "NULL", "but", "check", "anyway", "for", "good", "measure" ]
static void gp_free_stroke(bGPDframe *gpf, bGPDstroke *gps) { if (gps->points) { MEM_freeN(gps->points); } if (gps->dvert) { BKE_gpencil_free_stroke_weights(gps); MEM_freeN(gps->dvert); } if (gps->triangles) { MEM_freeN(gps->triangles); } BLI_freelinkN(&gpf->strokes, gps); }
[ "static", "void", "gp_free_stroke", "(", "bGPDframe", "*", "gpf", ",", "bGPDstroke", "*", "gps", ")", "{", "if", "(", "gps", "->", "points", ")", "{", "MEM_freeN", "(", "gps", "->", "points", ")", ";", "}", "if", "(", "gps", "->", "dvert", ")", "{", "BKE_gpencil_free_stroke_weights", "(", "gps", ")", ";", "MEM_freeN", "(", "gps", "->", "dvert", ")", ";", "}", "if", "(", "gps", "->", "triangles", ")", "{", "MEM_freeN", "(", "gps", "->", "triangles", ")", ";", "}", "BLI_freelinkN", "(", "&", "gpf", "->", "strokes", ",", "gps", ")", ";", "}" ]
helper to free a stroke NOTE: gps->dvert and gps->triangles should be NULL, but check anyway for good measure
[ "helper", "to", "free", "a", "stroke", "NOTE", ":", "gps", "-", ">", "dvert", "and", "gps", "-", ">", "triangles", "should", "be", "NULL", "but", "check", "anyway", "for", "good", "measure" ]
[]
[ { "param": "gpf", "type": "bGPDframe" }, { "param": "gps", "type": "bGPDstroke" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_eraser_is_occluded
bool
static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, const int x, const int y) { if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { RegionView3D *rv3d = p->ar->regiondata; const int mval_i[2] = {x, y}; float mval_3d[3]; if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); const float depth_pt = view3d_point_depth(rv3d, &pt->x); if (depth_pt > depth_mval) { return true; } } } return false; }
/* only erase stroke points that are visible (3d view) */
only erase stroke points that are visible (3d view)
[ "only", "erase", "stroke", "points", "that", "are", "visible", "(", "3d", "view", ")" ]
static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, const int x, const int y) { if ((p->sa->spacetype == SPACE_VIEW3D) && (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH)) { RegionView3D *rv3d = p->ar->regiondata; const int mval_i[2] = {x, y}; float mval_3d[3]; if (ED_view3d_autodist_simple(p->ar, mval_i, mval_3d, 0, NULL)) { const float depth_mval = view3d_point_depth(rv3d, mval_3d); const float depth_pt = view3d_point_depth(rv3d, &pt->x); if (depth_pt > depth_mval) { return true; } } } return false; }
[ "static", "bool", "gp_stroke_eraser_is_occluded", "(", "tGPsdata", "*", "p", ",", "const", "bGPDspoint", "*", "pt", ",", "const", "int", "x", ",", "const", "int", "y", ")", "{", "if", "(", "(", "p", "->", "sa", "->", "spacetype", "==", "SPACE_VIEW3D", ")", "&&", "(", "p", "->", "flags", "&", "GP_PAINTFLAG_V3D_ERASER_DEPTH", ")", ")", "{", "RegionView3D", "*", "rv3d", "=", "p", "->", "ar", "->", "regiondata", ";", "const", "int", "mval_i", "[", "2", "]", "=", "{", "x", ",", "y", "}", ";", "float", "mval_3d", "[", "3", "]", ";", "if", "(", "ED_view3d_autodist_simple", "(", "p", "->", "ar", ",", "mval_i", ",", "mval_3d", ",", "0", ",", "NULL", ")", ")", "{", "const", "float", "depth_mval", "=", "view3d_point_depth", "(", "rv3d", ",", "mval_3d", ")", ";", "const", "float", "depth_pt", "=", "view3d_point_depth", "(", "rv3d", ",", "&", "pt", "->", "x", ")", ";", "if", "(", "depth_pt", ">", "depth_mval", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
only erase stroke points that are visible (3d view)
[ "only", "erase", "stroke", "points", "that", "are", "visible", "(", "3d", "view", ")" ]
[]
[ { "param": "p", "type": "tGPsdata" }, { "param": "pt", "type": "bGPDspoint" }, { "param": "x", "type": "int" }, { "param": "y", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pt", "type": "bGPDspoint", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_eraser_dostroke
void
static void gp_stroke_eraser_dostroke(tGPsdata *p, bGPDframe *gpf, bGPDstroke *gps, const float mval[2], const float mvalo[2], const int radius, const rcti *rect) { bGPDspoint *pt1, *pt2; int pc1[2] = {0}; int pc2[2] = {0}; int i; int mval_i[2]; round_v2i_v2fl(mval_i, mval); if (gps->totpoints == 0) { /* just free stroke */ gp_free_stroke(gpf, gps); } else if (gps->totpoints == 1) { /* only process if it hasn't been masked out... */ if (!(p->flags & GP_PAINTFLAG_SELECTMASK) || (gps->points->flag & GP_SPOINT_SELECT)) { gp_point_to_xy(&p->gsc, gps, gps->points, &pc1[0], &pc1[1]); /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ if (len_v2v2_int(mval_i, pc1) <= radius) { /* free stroke */ gp_free_stroke(gpf, gps); } } } } else { /* Perform culling? */ bool do_cull = false; /* Clear Tags * * Note: It's better this way, as we are sure that * we don't miss anything, though things will be * slightly slower as a result */ for (i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; pt->flag &= ~GP_SPOINT_TAG; } /* First Pass: Loop over the points in the stroke * 1) Thin out parts of the stroke under the brush * 2) Tag "too thin" parts for removal (in second pass) */ for (i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ pt1 = gps->points + i; pt2 = gps->points + i + 1; /* only process if it hasn't been masked out... */ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { continue; } gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]); gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]); /* Check that point segment of the boundbox of the eraser stroke */ if (((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { /* Check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant */ if (gp_stroke_inside_circle(mval, mvalo, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { if ((gp_stroke_eraser_is_occluded(p, pt1, pc1[0], pc1[1]) == false) || (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) { /* Edge is affected - Check individual points now */ if (len_v2v2_int(mval_i, pc1) <= radius) { pt1->flag |= GP_SPOINT_TAG; } if (len_v2v2_int(mval_i, pc2) <= radius) { pt2->flag |= GP_SPOINT_TAG; } do_cull = true; } } } } /* Second Pass: Remove any points that are tagged */ if (do_cull) { gp_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0); } } }
/* eraser tool - evaluation per stroke */ /* TODO: this could really do with some optimization (KD-Tree/BVH?) */
eraser tool - evaluation per stroke TODO: this could really do with some optimization (KD-Tree/BVH?)
[ "eraser", "tool", "-", "evaluation", "per", "stroke", "TODO", ":", "this", "could", "really", "do", "with", "some", "optimization", "(", "KD", "-", "Tree", "/", "BVH?", ")" ]
static void gp_stroke_eraser_dostroke(tGPsdata *p, bGPDframe *gpf, bGPDstroke *gps, const float mval[2], const float mvalo[2], const int radius, const rcti *rect) { bGPDspoint *pt1, *pt2; int pc1[2] = {0}; int pc2[2] = {0}; int i; int mval_i[2]; round_v2i_v2fl(mval_i, mval); if (gps->totpoints == 0) { gp_free_stroke(gpf, gps); } else if (gps->totpoints == 1) { if (!(p->flags & GP_PAINTFLAG_SELECTMASK) || (gps->points->flag & GP_SPOINT_SELECT)) { gp_point_to_xy(&p->gsc, gps, gps->points, &pc1[0], &pc1[1]); if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { if (len_v2v2_int(mval_i, pc1) <= radius) { gp_free_stroke(gpf, gps); } } } } else { bool do_cull = false; for (i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; pt->flag &= ~GP_SPOINT_TAG; } for (i = 0; (i + 1) < gps->totpoints; i++) { pt1 = gps->points + i; pt2 = gps->points + i + 1; if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) { continue; } gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]); gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]); if (((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) || ((!ELEM(V2D_IS_CLIPPED, pc2[0], pc2[1])) && BLI_rcti_isect_pt(rect, pc2[0], pc2[1]))) { if (gp_stroke_inside_circle(mval, mvalo, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { if ((gp_stroke_eraser_is_occluded(p, pt1, pc1[0], pc1[1]) == false) || (gp_stroke_eraser_is_occluded(p, pt2, pc2[0], pc2[1]) == false)) { if (len_v2v2_int(mval_i, pc1) <= radius) { pt1->flag |= GP_SPOINT_TAG; } if (len_v2v2_int(mval_i, pc2) <= radius) { pt2->flag |= GP_SPOINT_TAG; } do_cull = true; } } } } if (do_cull) { gp_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG, false, 0); } } }
[ "static", "void", "gp_stroke_eraser_dostroke", "(", "tGPsdata", "*", "p", ",", "bGPDframe", "*", "gpf", ",", "bGPDstroke", "*", "gps", ",", "const", "float", "mval", "[", "2", "]", ",", "const", "float", "mvalo", "[", "2", "]", ",", "const", "int", "radius", ",", "const", "rcti", "*", "rect", ")", "{", "bGPDspoint", "*", "pt1", ",", "*", "pt2", ";", "int", "pc1", "[", "2", "]", "=", "{", "0", "}", ";", "int", "pc2", "[", "2", "]", "=", "{", "0", "}", ";", "int", "i", ";", "int", "mval_i", "[", "2", "]", ";", "round_v2i_v2fl", "(", "mval_i", ",", "mval", ")", ";", "if", "(", "gps", "->", "totpoints", "==", "0", ")", "{", "gp_free_stroke", "(", "gpf", ",", "gps", ")", ";", "}", "else", "if", "(", "gps", "->", "totpoints", "==", "1", ")", "{", "if", "(", "!", "(", "p", "->", "flags", "&", "GP_PAINTFLAG_SELECTMASK", ")", "||", "(", "gps", "->", "points", "->", "flag", "&", "GP_SPOINT_SELECT", ")", ")", "{", "gp_point_to_xy", "(", "&", "p", "->", "gsc", ",", "gps", ",", "gps", "->", "points", ",", "&", "pc1", "[", "0", "]", ",", "&", "pc1", "[", "1", "]", ")", ";", "if", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ")", ")", "{", "if", "(", "len_v2v2_int", "(", "mval_i", ",", "pc1", ")", "<=", "radius", ")", "{", "gp_free_stroke", "(", "gpf", ",", "gps", ")", ";", "}", "}", "}", "}", "else", "{", "bool", "do_cull", "=", "false", ";", "for", "(", "i", "=", "0", ";", "i", "<", "gps", "->", "totpoints", ";", "i", "++", ")", "{", "bGPDspoint", "*", "pt", "=", "&", "gps", "->", "points", "[", "i", "]", ";", "pt", "->", "flag", "&=", "~", "GP_SPOINT_TAG", ";", "}", "for", "(", "i", "=", "0", ";", "(", "i", "+", "1", ")", "<", "gps", "->", "totpoints", ";", "i", "++", ")", "{", "pt1", "=", "gps", "->", "points", "+", "i", ";", "pt2", "=", "gps", "->", "points", "+", "i", "+", "1", ";", "if", "(", "(", "p", "->", "flags", "&", "GP_PAINTFLAG_SELECTMASK", ")", "&&", "!", "(", "gps", "->", "points", "->", "flag", "&", "GP_SPOINT_SELECT", ")", ")", "{", "continue", ";", "}", "gp_point_to_xy", "(", "&", "p", "->", "gsc", ",", "gps", ",", "pt1", ",", "&", "pc1", "[", "0", "]", ",", "&", "pc1", "[", "1", "]", ")", ";", "gp_point_to_xy", "(", "&", "p", "->", "gsc", ",", "gps", ",", "pt2", ",", "&", "pc2", "[", "0", "]", ",", "&", "pc2", "[", "1", "]", ")", ";", "if", "(", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ")", ")", "||", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "pc2", "[", "0", "]", ",", "pc2", "[", "1", "]", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "pc2", "[", "0", "]", ",", "pc2", "[", "1", "]", ")", ")", ")", "{", "if", "(", "gp_stroke_inside_circle", "(", "mval", ",", "mvalo", ",", "radius", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ",", "pc2", "[", "0", "]", ",", "pc2", "[", "1", "]", ")", ")", "{", "if", "(", "(", "gp_stroke_eraser_is_occluded", "(", "p", ",", "pt1", ",", "pc1", "[", "0", "]", ",", "pc1", "[", "1", "]", ")", "==", "false", ")", "||", "(", "gp_stroke_eraser_is_occluded", "(", "p", ",", "pt2", ",", "pc2", "[", "0", "]", ",", "pc2", "[", "1", "]", ")", "==", "false", ")", ")", "{", "if", "(", "len_v2v2_int", "(", "mval_i", ",", "pc1", ")", "<=", "radius", ")", "{", "pt1", "->", "flag", "|=", "GP_SPOINT_TAG", ";", "}", "if", "(", "len_v2v2_int", "(", "mval_i", ",", "pc2", ")", "<=", "radius", ")", "{", "pt2", "->", "flag", "|=", "GP_SPOINT_TAG", ";", "}", "do_cull", "=", "true", ";", "}", "}", "}", "}", "if", "(", "do_cull", ")", "{", "gp_stroke_delete_tagged_points", "(", "gpf", ",", "gps", ",", "gps", "->", "next", ",", "GP_SPOINT_TAG", ",", "false", ",", "0", ")", ";", "}", "}", "}" ]
eraser tool - evaluation per stroke TODO: this could really do with some optimization (KD-Tree/BVH?)
[ "eraser", "tool", "-", "evaluation", "per", "stroke", "TODO", ":", "this", "could", "really", "do", "with", "some", "optimization", "(", "KD", "-", "Tree", "/", "BVH?", ")" ]
[ "/* just free stroke */", "/* only process if it hasn't been masked out... */", "/* do boundbox check first */", "/* only check if point is inside */", "/* free stroke */", "/* Perform culling? */", "/* Clear Tags\n *\n * Note: It's better this way, as we are sure that\n * we don't miss anything, though things will be\n * slightly slower as a result\n */", "/* First Pass: Loop over the points in the stroke\n * 1) Thin out parts of the stroke under the brush\n * 2) Tag \"too thin\" parts for removal (in second pass)\n */", "/* get points to work with */", "/* only process if it hasn't been masked out... */", "/* Check that point segment of the boundbox of the eraser stroke */", "/* Check if point segment of stroke had anything to do with\n * eraser region (either within stroke painted, or on its lines)\n * - this assumes that linewidth is irrelevant\n */", "/* Edge is affected - Check individual points now */", "/* Second Pass: Remove any points that are tagged */" ]
[ { "param": "p", "type": "tGPsdata" }, { "param": "gpf", "type": "bGPDframe" }, { "param": "gps", "type": "bGPDstroke" }, { "param": "mval", "type": "float" }, { "param": "mvalo", "type": "float" }, { "param": "radius", "type": "int" }, { "param": "rect", "type": "rcti" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mval", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mvalo", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "radius", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rect", "type": "rcti", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_doeraser
void
static void gp_stroke_doeraser(tGPsdata *p) { bGPDframe *gpf = p->gpf; bGPDstroke *gps, *gpn; rcti rect; /* rect is rectangle of eraser */ rect.xmin = p->mval[0] - p->radius; rect.ymin = p->mval[1] - p->radius; rect.xmax = p->mval[0] + p->radius; rect.ymax = p->mval[1] + p->radius; if (p->sa->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0); } } /* loop over strokes of active layer only (session init already took care of ensuring validity), * checking segments for intersections to remove */ for (gps = gpf->strokes.first; gps; gps = gpn) { gpn = gps->next; /* Not all strokes in the datablock may be valid in the current editor/context * (e.g. 2D space strokes in the 3D view, if the same datablock is shared) */ if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) { gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, p->mvalo, p->radius, &rect); } } }
/* erase strokes which fall under the eraser strokes */
erase strokes which fall under the eraser strokes
[ "erase", "strokes", "which", "fall", "under", "the", "eraser", "strokes" ]
static void gp_stroke_doeraser(tGPsdata *p) { bGPDframe *gpf = p->gpf; bGPDstroke *gps, *gpn; rcti rect; rect.xmin = p->mval[0] - p->radius; rect.ymin = p->mval[1] - p->radius; rect.xmax = p->mval[0] + p->radius; rect.ymax = p->mval[1] + p->radius; if (p->sa->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->depsgraph, p->ar, v3d, 0); } } for (gps = gpf->strokes.first; gps; gps = gpn) { gpn = gps->next; if (ED_gpencil_stroke_can_use_direct(p->sa, gps)) { gp_stroke_eraser_dostroke(p, gpf, gps, p->mval, p->mvalo, p->radius, &rect); } } }
[ "static", "void", "gp_stroke_doeraser", "(", "tGPsdata", "*", "p", ")", "{", "bGPDframe", "*", "gpf", "=", "p", "->", "gpf", ";", "bGPDstroke", "*", "gps", ",", "*", "gpn", ";", "rcti", "rect", ";", "rect", ".", "xmin", "=", "p", "->", "mval", "[", "0", "]", "-", "p", "->", "radius", ";", "rect", ".", "ymin", "=", "p", "->", "mval", "[", "1", "]", "-", "p", "->", "radius", ";", "rect", ".", "xmax", "=", "p", "->", "mval", "[", "0", "]", "+", "p", "->", "radius", ";", "rect", ".", "ymax", "=", "p", "->", "mval", "[", "1", "]", "+", "p", "->", "radius", ";", "if", "(", "p", "->", "sa", "->", "spacetype", "==", "SPACE_VIEW3D", ")", "{", "if", "(", "p", "->", "flags", "&", "GP_PAINTFLAG_V3D_ERASER_DEPTH", ")", "{", "View3D", "*", "v3d", "=", "p", "->", "sa", "->", "spacedata", ".", "first", ";", "view3d_region_operator_needs_opengl", "(", "p", "->", "win", ",", "p", "->", "ar", ")", ";", "ED_view3d_autodist_init", "(", "p", "->", "depsgraph", ",", "p", "->", "ar", ",", "v3d", ",", "0", ")", ";", "}", "}", "for", "(", "gps", "=", "gpf", "->", "strokes", ".", "first", ";", "gps", ";", "gps", "=", "gpn", ")", "{", "gpn", "=", "gps", "->", "next", ";", "if", "(", "ED_gpencil_stroke_can_use_direct", "(", "p", "->", "sa", ",", "gps", ")", ")", "{", "gp_stroke_eraser_dostroke", "(", "p", ",", "gpf", ",", "gps", ",", "p", "->", "mval", ",", "p", "->", "mvalo", ",", "p", "->", "radius", ",", "&", "rect", ")", ";", "}", "}", "}" ]
erase strokes which fall under the eraser strokes
[ "erase", "strokes", "which", "fall", "under", "the", "eraser", "strokes" ]
[ "/* rect is rectangle of eraser */", "/* loop over strokes of active layer only (session init already took care of ensuring validity),\n * checking segments for intersections to remove\n */", "/* Not all strokes in the datablock may be valid in the current editor/context\n * (e.g. 2D space strokes in the 3D view, if the same datablock is shared)\n */" ]
[ { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_session_validatebuffer
void
static void gp_session_validatebuffer(tGPsdata *p) { bGPdata *gpd = p->gpd; gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure( gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, true); /* reset flags */ gpd->runtime.sbuffer_sflag = 0; /* reset inittime */ p->inittime = 0.0; }
/* clear the session buffers (call this before AND after a paint operation) */
clear the session buffers (call this before AND after a paint operation)
[ "clear", "the", "session", "buffers", "(", "call", "this", "before", "AND", "after", "a", "paint", "operation", ")" ]
static void gp_session_validatebuffer(tGPsdata *p) { bGPdata *gpd = p->gpd; gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure( gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, true); gpd->runtime.sbuffer_sflag = 0; p->inittime = 0.0; }
[ "static", "void", "gp_session_validatebuffer", "(", "tGPsdata", "*", "p", ")", "{", "bGPdata", "*", "gpd", "=", "p", "->", "gpd", ";", "gpd", "->", "runtime", ".", "sbuffer", "=", "ED_gpencil_sbuffer_ensure", "(", "gpd", "->", "runtime", ".", "sbuffer", ",", "&", "gpd", "->", "runtime", ".", "sbuffer_size", ",", "&", "gpd", "->", "runtime", ".", "sbuffer_used", ",", "true", ")", ";", "gpd", "->", "runtime", ".", "sbuffer_sflag", "=", "0", ";", "p", "->", "inittime", "=", "0.0", ";", "}" ]
clear the session buffers (call this before AND after a paint operation)
[ "clear", "the", "session", "buffers", "(", "call", "this", "before", "AND", "after", "a", "paint", "operation", ")" ]
[ "/* reset flags */", "/* reset inittime */" ]
[ { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_session_initdata
bool
static bool gp_session_initdata(bContext *C, tGPsdata *p) { Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = NULL; ScrArea *curarea = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: No active view for painting\n"); } return 0; } /* pass on current scene and window */ p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); unit_m4(p->imat); unit_m4(p->mat); switch (curarea->spacetype) { /* supported views first */ case SPACE_VIEW3D: { /* View3D *v3d = curarea->spacedata.first; */ /* RegionView3D *rv3d = ar->regiondata; */ /* set current area * - must verify that region data is 3D-view (and not something else) */ /* CAUTION: If this is the "toolbar", then this will change on the first stroke */ p->sa = curarea; p->ar = ar; p->align_flag = &ts->annotate_v3d_align; if (ar->regiondata == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf( "Error: 3D-View active region doesn't have any region data, so cannot be " "drawable\n"); } return 0; } break; } case SPACE_NODE: { /* SpaceNode *snode = curarea->spacedata.first; */ /* set current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_v2d_align; break; } case SPACE_SEQ: { SpaceSeq *sseq = curarea->spacedata.first; /* set current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_seq_align; /* check that gpencil data is allowed to be drawn */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); } return 0; } break; } case SPACE_IMAGE: { /* SpaceImage *sima = curarea->spacedata.first; */ /* set the current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_ima_align; break; } case SPACE_CLIP: { SpaceClip *sc = curarea->spacedata.first; MovieClip *clip = ED_space_clip_get_clip(sc); if (clip == NULL) { p->status = GP_STATUS_ERROR; return false; } /* set the current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_v2d_align; invert_m4_m4(p->imat, sc->unistabmat); /* custom color for new layer */ p->custom_color[0] = 1.0f; p->custom_color[1] = 0.0f; p->custom_color[2] = 0.5f; p->custom_color[3] = 0.9f; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingMarker *marker = track ? BKE_tracking_marker_get(track, framenr) : NULL; if (marker) { p->imat[3][0] -= marker->pos[0]; p->imat[3][1] -= marker->pos[1]; } else { p->status = GP_STATUS_ERROR; return false; } } invert_m4_m4(p->mat, p->imat); copy_m4_m4(p->gsc.mat, p->mat); break; } /* unsupported views */ default: { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Annotations are not supported in this editor\n"); } return 0; } } /* get gp-data */ gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr); if ((gpd_ptr == NULL) || !ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Current context doesn't allow for any Annotation data\n"); } return 0; } else { /* if no existing GPencil block exists, add one */ if (*gpd_ptr == NULL) { bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations"); *gpd_ptr = gpd; /* mark datablock as being used for annotations */ gpd->flag |= GP_DATA_ANNOTATIONS; } p->gpd = *gpd_ptr; } if (ED_gpencil_session_active() == 0) { /* initialize undo stack, * also, existing undo stack would make buffer drawn */ gpencil_undo_init(p->gpd); } /* clear out buffer (stored in gp-data), in case something contaminated it */ gp_session_validatebuffer(p); return 1; }
/* (re)init new painting data */
(re)init new painting data
[ "(", "re", ")", "init", "new", "painting", "data" ]
static bool gp_session_initdata(bContext *C, tGPsdata *p) { Main *bmain = CTX_data_main(C); bGPdata **gpd_ptr = NULL; ScrArea *curarea = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); if (curarea == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: No active view for painting\n"); } return 0; } p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); unit_m4(p->imat); unit_m4(p->mat); switch (curarea->spacetype) { case SPACE_VIEW3D: { p->sa = curarea; p->ar = ar; p->align_flag = &ts->annotate_v3d_align; if (ar->regiondata == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf( "Error: 3D-View active region doesn't have any region data, so cannot be " "drawable\n"); } return 0; } break; } case SPACE_NODE: { p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_v2d_align; break; } case SPACE_SEQ: { SpaceSeq *sseq = curarea->spacedata.first; p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_seq_align; if (sseq->mainb == SEQ_DRAW_SEQUENCE) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); } return 0; } break; } case SPACE_IMAGE: { p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_ima_align; break; } case SPACE_CLIP: { SpaceClip *sc = curarea->spacedata.first; MovieClip *clip = ED_space_clip_get_clip(sc); if (clip == NULL) { p->status = GP_STATUS_ERROR; return false; } p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_v2d_align; invert_m4_m4(p->imat, sc->unistabmat); p->custom_color[0] = 1.0f; p->custom_color[1] = 0.0f; p->custom_color[2] = 0.5f; p->custom_color[3] = 0.9f; if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); MovieTrackingMarker *marker = track ? BKE_tracking_marker_get(track, framenr) : NULL; if (marker) { p->imat[3][0] -= marker->pos[0]; p->imat[3][1] -= marker->pos[1]; } else { p->status = GP_STATUS_ERROR; return false; } } invert_m4_m4(p->mat, p->imat); copy_m4_m4(p->gsc.mat, p->mat); break; } default: { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Annotations are not supported in this editor\n"); } return 0; } } gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr); if ((gpd_ptr == NULL) || !ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Current context doesn't allow for any Annotation data\n"); } return 0; } else { if (*gpd_ptr == NULL) { bGPdata *gpd = BKE_gpencil_data_addnew(bmain, "Annotations"); *gpd_ptr = gpd; gpd->flag |= GP_DATA_ANNOTATIONS; } p->gpd = *gpd_ptr; } if (ED_gpencil_session_active() == 0) { gpencil_undo_init(p->gpd); } gp_session_validatebuffer(p); return 1; }
[ "static", "bool", "gp_session_initdata", "(", "bContext", "*", "C", ",", "tGPsdata", "*", "p", ")", "{", "Main", "*", "bmain", "=", "CTX_data_main", "(", "C", ")", ";", "bGPdata", "*", "*", "gpd_ptr", "=", "NULL", ";", "ScrArea", "*", "curarea", "=", "CTX_wm_area", "(", "C", ")", ";", "ARegion", "*", "ar", "=", "CTX_wm_region", "(", "C", ")", ";", "ToolSettings", "*", "ts", "=", "CTX_data_tool_settings", "(", "C", ")", ";", "if", "(", "curarea", "==", "NULL", ")", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "return", "0", ";", "}", "p", "->", "bmain", "=", "CTX_data_main", "(", "C", ")", ";", "p", "->", "scene", "=", "CTX_data_scene", "(", "C", ")", ";", "p", "->", "depsgraph", "=", "CTX_data_ensure_evaluated_depsgraph", "(", "C", ")", ";", "p", "->", "win", "=", "CTX_wm_window", "(", "C", ")", ";", "unit_m4", "(", "p", "->", "imat", ")", ";", "unit_m4", "(", "p", "->", "mat", ")", ";", "switch", "(", "curarea", "->", "spacetype", ")", "{", "case", "SPACE_VIEW3D", ":", "{", "p", "->", "sa", "=", "curarea", ";", "p", "->", "ar", "=", "ar", ";", "p", "->", "align_flag", "=", "&", "ts", "->", "annotate_v3d_align", ";", "if", "(", "ar", "->", "regiondata", "==", "NULL", ")", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\"", "\"", "\\n", "\"", ")", ";", "}", "return", "0", ";", "}", "break", ";", "}", "case", "SPACE_NODE", ":", "{", "p", "->", "sa", "=", "curarea", ";", "p", "->", "ar", "=", "ar", ";", "p", "->", "v2d", "=", "&", "ar", "->", "v2d", ";", "p", "->", "align_flag", "=", "&", "ts", "->", "gpencil_v2d_align", ";", "break", ";", "}", "case", "SPACE_SEQ", ":", "{", "SpaceSeq", "*", "sseq", "=", "curarea", "->", "spacedata", ".", "first", ";", "p", "->", "sa", "=", "curarea", ";", "p", "->", "ar", "=", "ar", ";", "p", "->", "v2d", "=", "&", "ar", "->", "v2d", ";", "p", "->", "align_flag", "=", "&", "ts", "->", "gpencil_seq_align", ";", "if", "(", "sseq", "->", "mainb", "==", "SEQ_DRAW_SEQUENCE", ")", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "return", "0", ";", "}", "break", ";", "}", "case", "SPACE_IMAGE", ":", "{", "p", "->", "sa", "=", "curarea", ";", "p", "->", "ar", "=", "ar", ";", "p", "->", "v2d", "=", "&", "ar", "->", "v2d", ";", "p", "->", "align_flag", "=", "&", "ts", "->", "gpencil_ima_align", ";", "break", ";", "}", "case", "SPACE_CLIP", ":", "{", "SpaceClip", "*", "sc", "=", "curarea", "->", "spacedata", ".", "first", ";", "MovieClip", "*", "clip", "=", "ED_space_clip_get_clip", "(", "sc", ")", ";", "if", "(", "clip", "==", "NULL", ")", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "return", "false", ";", "}", "p", "->", "sa", "=", "curarea", ";", "p", "->", "ar", "=", "ar", ";", "p", "->", "v2d", "=", "&", "ar", "->", "v2d", ";", "p", "->", "align_flag", "=", "&", "ts", "->", "gpencil_v2d_align", ";", "invert_m4_m4", "(", "p", "->", "imat", ",", "sc", "->", "unistabmat", ")", ";", "p", "->", "custom_color", "[", "0", "]", "=", "1.0f", ";", "p", "->", "custom_color", "[", "1", "]", "=", "0.0f", ";", "p", "->", "custom_color", "[", "2", "]", "=", "0.5f", ";", "p", "->", "custom_color", "[", "3", "]", "=", "0.9f", ";", "if", "(", "sc", "->", "gpencil_src", "==", "SC_GPENCIL_SRC_TRACK", ")", "{", "int", "framenr", "=", "ED_space_clip_get_clip_frame_number", "(", "sc", ")", ";", "MovieTrackingTrack", "*", "track", "=", "BKE_tracking_track_get_active", "(", "&", "clip", "->", "tracking", ")", ";", "MovieTrackingMarker", "*", "marker", "=", "track", "?", "BKE_tracking_marker_get", "(", "track", ",", "framenr", ")", ":", "NULL", ";", "if", "(", "marker", ")", "{", "p", "->", "imat", "[", "3", "]", "[", "0", "]", "-=", "marker", "->", "pos", "[", "0", "]", ";", "p", "->", "imat", "[", "3", "]", "[", "1", "]", "-=", "marker", "->", "pos", "[", "1", "]", ";", "}", "else", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "return", "false", ";", "}", "}", "invert_m4_m4", "(", "p", "->", "mat", ",", "p", "->", "imat", ")", ";", "copy_m4_m4", "(", "p", "->", "gsc", ".", "mat", ",", "p", "->", "mat", ")", ";", "break", ";", "}", "default", ":", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "return", "0", ";", "}", "}", "gpd_ptr", "=", "ED_gpencil_data_get_pointers", "(", "C", ",", "&", "p", "->", "ownerPtr", ")", ";", "if", "(", "(", "gpd_ptr", "==", "NULL", ")", "||", "!", "ED_gpencil_data_owner_is_annotation", "(", "&", "p", "->", "ownerPtr", ")", ")", "{", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "return", "0", ";", "}", "else", "{", "if", "(", "*", "gpd_ptr", "==", "NULL", ")", "{", "bGPdata", "*", "gpd", "=", "BKE_gpencil_data_addnew", "(", "bmain", ",", "\"", "\"", ")", ";", "*", "gpd_ptr", "=", "gpd", ";", "gpd", "->", "flag", "|=", "GP_DATA_ANNOTATIONS", ";", "}", "p", "->", "gpd", "=", "*", "gpd_ptr", ";", "}", "if", "(", "ED_gpencil_session_active", "(", ")", "==", "0", ")", "{", "gpencil_undo_init", "(", "p", "->", "gpd", ")", ";", "}", "gp_session_validatebuffer", "(", "p", ")", ";", "return", "1", ";", "}" ]
(re)init new painting data
[ "(", "re", ")", "init", "new", "painting", "data" ]
[ "/* make sure the active view (at the starting time) is a 3d-view */", "/* pass on current scene and window */", "/* supported views first */", "/* View3D *v3d = curarea->spacedata.first; */", "/* RegionView3D *rv3d = ar->regiondata; */", "/* set current area\n * - must verify that region data is 3D-view (and not something else)\n */", "/* CAUTION: If this is the \"toolbar\", then this will change on the first stroke */", "/* SpaceNode *snode = curarea->spacedata.first; */", "/* set current area */", "/* set current area */", "/* check that gpencil data is allowed to be drawn */", "/* SpaceImage *sima = curarea->spacedata.first; */", "/* set the current area */", "/* set the current area */", "/* custom color for new layer */", "/* unsupported views */", "/* get gp-data */", "/* if no existing GPencil block exists, add one */", "/* mark datablock as being used for annotations */", "/* initialize undo stack,\n * also, existing undo stack would make buffer drawn\n */", "/* clear out buffer (stored in gp-data), in case something contaminated it */" ]
[ { "param": "C", "type": "bContext" }, { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_paint_strokeend
void
static void gp_paint_strokeend(tGPsdata *p) { ToolSettings *ts = p->scene->toolsettings; /* for surface sketching, need to set the right OpenGL context stuff so that * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ if ((p->gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { /* transfer stroke to frame */ gp_stroke_newfrombuffer(p); } /* clean up buffer now */ gp_session_validatebuffer(p); }
/* finish off a stroke (clears buffer, but doesn't finish the paint operation) */
finish off a stroke (clears buffer, but doesn't finish the paint operation)
[ "finish", "off", "a", "stroke", "(", "clears", "buffer", "but", "doesn", "'", "t", "finish", "the", "paint", "operation", ")" ]
static void gp_paint_strokeend(tGPsdata *p) { ToolSettings *ts = p->scene->toolsettings; if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init( p->depsgraph, p->ar, v3d, (ts->annotate_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } if ((p->gpd->runtime.sbuffer_sflag & GP_STROKE_ERASER) == 0) { gp_stroke_newfrombuffer(p); } gp_session_validatebuffer(p); }
[ "static", "void", "gp_paint_strokeend", "(", "tGPsdata", "*", "p", ")", "{", "ToolSettings", "*", "ts", "=", "p", "->", "scene", "->", "toolsettings", ";", "if", "(", "gpencil_project_check", "(", "p", ")", ")", "{", "View3D", "*", "v3d", "=", "p", "->", "sa", "->", "spacedata", ".", "first", ";", "view3d_region_operator_needs_opengl", "(", "p", "->", "win", ",", "p", "->", "ar", ")", ";", "ED_view3d_autodist_init", "(", "p", "->", "depsgraph", ",", "p", "->", "ar", ",", "v3d", ",", "(", "ts", "->", "annotate_v3d_align", "&", "GP_PROJECT_DEPTH_STROKE", ")", "?", "1", ":", "0", ")", ";", "}", "if", "(", "(", "p", "->", "gpd", "->", "runtime", ".", "sbuffer_sflag", "&", "GP_STROKE_ERASER", ")", "==", "0", ")", "{", "gp_stroke_newfrombuffer", "(", "p", ")", ";", "}", "gp_session_validatebuffer", "(", "p", ")", ";", "}" ]
finish off a stroke (clears buffer, but doesn't finish the paint operation)
[ "finish", "off", "a", "stroke", "(", "clears", "buffer", "but", "doesn", "'", "t", "finish", "the", "paint", "operation", ")" ]
[ "/* for surface sketching, need to set the right OpenGL context stuff so that\n * the conversions will project the values correctly...\n */", "/* need to restore the original projection settings before packing up */", "/* check if doing eraser or not */", "/* transfer stroke to frame */", "/* clean up buffer now */" ]
[ { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_toggle_eraser_cursor
void
static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short enable) { if (p->erasercursor && !enable) { /* clear cursor */ WM_paint_cursor_end(CTX_wm_manager(C), p->erasercursor); p->erasercursor = NULL; } else if (enable && !p->erasercursor) { /* enable cursor */ p->erasercursor = WM_paint_cursor_activate(CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, NULL, /* XXX */ gpencil_draw_eraser, p); } }
/* Turn brush cursor in 3D view on/off */
Turn brush cursor in 3D view on/off
[ "Turn", "brush", "cursor", "in", "3D", "view", "on", "/", "off" ]
static void gpencil_draw_toggle_eraser_cursor(bContext *C, tGPsdata *p, short enable) { if (p->erasercursor && !enable) { WM_paint_cursor_end(CTX_wm_manager(C), p->erasercursor); p->erasercursor = NULL; } else if (enable && !p->erasercursor) { p->erasercursor = WM_paint_cursor_activate(CTX_wm_manager(C), SPACE_TYPE_ANY, RGN_TYPE_ANY, NULL, gpencil_draw_eraser, p); } }
[ "static", "void", "gpencil_draw_toggle_eraser_cursor", "(", "bContext", "*", "C", ",", "tGPsdata", "*", "p", ",", "short", "enable", ")", "{", "if", "(", "p", "->", "erasercursor", "&&", "!", "enable", ")", "{", "WM_paint_cursor_end", "(", "CTX_wm_manager", "(", "C", ")", ",", "p", "->", "erasercursor", ")", ";", "p", "->", "erasercursor", "=", "NULL", ";", "}", "else", "if", "(", "enable", "&&", "!", "p", "->", "erasercursor", ")", "{", "p", "->", "erasercursor", "=", "WM_paint_cursor_activate", "(", "CTX_wm_manager", "(", "C", ")", ",", "SPACE_TYPE_ANY", ",", "RGN_TYPE_ANY", ",", "NULL", ",", "gpencil_draw_eraser", ",", "p", ")", ";", "}", "}" ]
Turn brush cursor in 3D view on/off
[ "Turn", "brush", "cursor", "in", "3D", "view", "on", "/", "off" ]
[ "/* clear cursor */", "/* enable cursor */", "/* XXX */" ]
[ { "param": "C", "type": "bContext" }, { "param": "p", "type": "tGPsdata" }, { "param": "enable", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "enable", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_cursor_set
void
static void gpencil_draw_cursor_set(tGPsdata *p) { if (p->paintmode == GP_PAINTMODE_ERASER) { WM_cursor_modal_set(p->win, WM_CURSOR_ERASER); } else { WM_cursor_modal_set(p->win, WM_CURSOR_PAINT_BRUSH); } }
/* ensure that the correct cursor icon is set */
ensure that the correct cursor icon is set
[ "ensure", "that", "the", "correct", "cursor", "icon", "is", "set" ]
static void gpencil_draw_cursor_set(tGPsdata *p) { if (p->paintmode == GP_PAINTMODE_ERASER) { WM_cursor_modal_set(p->win, WM_CURSOR_ERASER); } else { WM_cursor_modal_set(p->win, WM_CURSOR_PAINT_BRUSH); } }
[ "static", "void", "gpencil_draw_cursor_set", "(", "tGPsdata", "*", "p", ")", "{", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_ERASER", ")", "{", "WM_cursor_modal_set", "(", "p", "->", "win", ",", "WM_CURSOR_ERASER", ")", ";", "}", "else", "{", "WM_cursor_modal_set", "(", "p", "->", "win", ",", "WM_CURSOR_PAINT_BRUSH", ")", ";", "}", "}" ]
ensure that the correct cursor icon is set
[ "ensure", "that", "the", "correct", "cursor", "icon", "is", "set" ]
[]
[ { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_status_indicators
void
static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p) { /* header prints */ switch (p->status) { case GP_STATUS_PAINTING: switch (p->paintmode) { case GP_PAINTMODE_DRAW_POLY: /* Provide usage tips, since this is modal, and unintuitive without hints */ ED_workspace_status_text( C, TIP_("Annotation Create Poly: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; default: /* Do nothing - the others are self explanatory, exit quickly once the mouse is released * Showing any text would just be annoying as it would flicker. */ break; } break; case GP_STATUS_IDLING: /* print status info */ switch (p->paintmode) { case GP_PAINTMODE_ERASER: ED_workspace_status_text(C, TIP_("Annotation Eraser: Hold and drag LMB or RMB to erase | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_STRAIGHT: ED_workspace_status_text(C, TIP_("Annotation Line Draw: Hold and drag LMB to draw | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW: ED_workspace_status_text(C, TIP_("Annotation Freehand Draw: Hold and drag LMB to draw | " "E/ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_POLY: ED_workspace_status_text( C, TIP_("Annotation Create Poly: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; default: /* unhandled future cases */ ED_workspace_status_text( C, TIP_("Annotation Session: ESC/Enter to end (or click outside this area)")); break; } break; case GP_STATUS_ERROR: case GP_STATUS_DONE: case GP_STATUS_CAPTURE: /* clear status string */ ED_workspace_status_text(C, NULL); break; } }
/* update UI indicators of status, including cursor and header prints */
update UI indicators of status, including cursor and header prints
[ "update", "UI", "indicators", "of", "status", "including", "cursor", "and", "header", "prints" ]
static void gpencil_draw_status_indicators(bContext *C, tGPsdata *p) { switch (p->status) { case GP_STATUS_PAINTING: switch (p->paintmode) { case GP_PAINTMODE_DRAW_POLY: ED_workspace_status_text( C, TIP_("Annotation Create Poly: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; default: break; } break; case GP_STATUS_IDLING: switch (p->paintmode) { case GP_PAINTMODE_ERASER: ED_workspace_status_text(C, TIP_("Annotation Eraser: Hold and drag LMB or RMB to erase | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_STRAIGHT: ED_workspace_status_text(C, TIP_("Annotation Line Draw: Hold and drag LMB to draw | " "ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW: ED_workspace_status_text(C, TIP_("Annotation Freehand Draw: Hold and drag LMB to draw | " "E/ESC/Enter to end (or click outside this area)")); break; case GP_PAINTMODE_DRAW_POLY: ED_workspace_status_text( C, TIP_("Annotation Create Poly: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; default: ED_workspace_status_text( C, TIP_("Annotation Session: ESC/Enter to end (or click outside this area)")); break; } break; case GP_STATUS_ERROR: case GP_STATUS_DONE: case GP_STATUS_CAPTURE: ED_workspace_status_text(C, NULL); break; } }
[ "static", "void", "gpencil_draw_status_indicators", "(", "bContext", "*", "C", ",", "tGPsdata", "*", "p", ")", "{", "switch", "(", "p", "->", "status", ")", "{", "case", "GP_STATUS_PAINTING", ":", "switch", "(", "p", "->", "paintmode", ")", "{", "case", "GP_PAINTMODE_DRAW_POLY", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", "\"", "\"", ")", ")", ";", "break", ";", "default", ":", "break", ";", "}", "break", ";", "case", "GP_STATUS_IDLING", ":", "switch", "(", "p", "->", "paintmode", ")", "{", "case", "GP_PAINTMODE_ERASER", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", "\"", "\"", ")", ")", ";", "break", ";", "case", "GP_PAINTMODE_DRAW_STRAIGHT", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", "\"", "\"", ")", ")", ";", "break", ";", "case", "GP_PAINTMODE_DRAW", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", "\"", "\"", ")", ")", ";", "break", ";", "case", "GP_PAINTMODE_DRAW_POLY", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", "\"", "\"", ")", ")", ";", "break", ";", "default", ":", "ED_workspace_status_text", "(", "C", ",", "TIP_", "(", "\"", "\"", ")", ")", ";", "break", ";", "}", "break", ";", "case", "GP_STATUS_ERROR", ":", "case", "GP_STATUS_DONE", ":", "case", "GP_STATUS_CAPTURE", ":", "ED_workspace_status_text", "(", "C", ",", "NULL", ")", ";", "break", ";", "}", "}" ]
update UI indicators of status, including cursor and header prints
[ "update", "UI", "indicators", "of", "status", "including", "cursor", "and", "header", "prints" ]
[ "/* header prints */", "/* Provide usage tips, since this is modal, and unintuitive without hints */", "/* Do nothing - the others are self explanatory, exit quickly once the mouse is released\n * Showing any text would just be annoying as it would flicker.\n */", "/* print status info */", "/* unhandled future cases */", "/* clear status string */" ]
[ { "param": "C", "type": "bContext" }, { "param": "p", "type": "tGPsdata" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_apply
void
static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph) { /* handle drawing/erasing -> test for erasing first */ if (p->paintmode == GP_PAINTMODE_ERASER) { /* do 'live' erasing now */ gp_stroke_doeraser(p); /* store used values */ p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; } /* Only add current point to buffer if mouse moved * (even though we got an event, it might be just noise). */ else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ gp_paint_strokeend(p); /* And start a new one!!! Else, projection errors! */ gp_paint_initstroke(p, p->paintmode, depsgraph); /* start a new stroke, starting from previous point */ /* XXX Must manually reset inittime... */ /* XXX We only need to reuse previous point if overflow! */ if (ok == GP_STROKEADD_OVERFLOW) { p->inittime = p->ocurtime; gp_stroke_addpoint(p, p->mvalo, p->opressure, p->ocurtime); } else { p->inittime = p->curtime; } gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); } else if (ok == GP_STROKEADD_INVALID) { /* the painting operation cannot continue... */ BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke"); p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Grease-Pencil Paint - Add Point Invalid\n"); } return; } /* store used values */ p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; p->ocurtime = p->curtime; } }
/* create a new stroke point at the point indicated by the painting context */
create a new stroke point at the point indicated by the painting context
[ "create", "a", "new", "stroke", "point", "at", "the", "point", "indicated", "by", "the", "painting", "context" ]
static void gpencil_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgraph) { if (p->paintmode == GP_PAINTMODE_ERASER) { gp_stroke_doeraser(p); p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; } else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { gp_paint_strokeend(p); gp_paint_initstroke(p, p->paintmode, depsgraph); if (ok == GP_STROKEADD_OVERFLOW) { p->inittime = p->ocurtime; gp_stroke_addpoint(p, p->mvalo, p->opressure, p->ocurtime); } else { p->inittime = p->curtime; } gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); } else if (ok == GP_STROKEADD_INVALID) { BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke"); p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) { printf("Error: Grease-Pencil Paint - Add Point Invalid\n"); } return; } p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; p->ocurtime = p->curtime; } }
[ "static", "void", "gpencil_draw_apply", "(", "wmOperator", "*", "op", ",", "tGPsdata", "*", "p", ",", "Depsgraph", "*", "depsgraph", ")", "{", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_ERASER", ")", "{", "gp_stroke_doeraser", "(", "p", ")", ";", "p", "->", "mvalo", "[", "0", "]", "=", "p", "->", "mval", "[", "0", "]", ";", "p", "->", "mvalo", "[", "1", "]", "=", "p", "->", "mval", "[", "1", "]", ";", "p", "->", "opressure", "=", "p", "->", "pressure", ";", "}", "else", "if", "(", "gp_stroke_filtermval", "(", "p", ",", "p", "->", "mval", ",", "p", "->", "mvalo", ")", ")", "{", "short", "ok", "=", "gp_stroke_addpoint", "(", "p", ",", "p", "->", "mval", ",", "p", "->", "pressure", ",", "p", "->", "curtime", ")", ";", "if", "(", "(", "ok", "==", "GP_STROKEADD_FULL", ")", "||", "(", "ok", "==", "GP_STROKEADD_OVERFLOW", ")", ")", "{", "gp_paint_strokeend", "(", "p", ")", ";", "gp_paint_initstroke", "(", "p", ",", "p", "->", "paintmode", ",", "depsgraph", ")", ";", "if", "(", "ok", "==", "GP_STROKEADD_OVERFLOW", ")", "{", "p", "->", "inittime", "=", "p", "->", "ocurtime", ";", "gp_stroke_addpoint", "(", "p", ",", "p", "->", "mvalo", ",", "p", "->", "opressure", ",", "p", "->", "ocurtime", ")", ";", "}", "else", "{", "p", "->", "inittime", "=", "p", "->", "curtime", ";", "}", "gp_stroke_addpoint", "(", "p", ",", "p", "->", "mval", ",", "p", "->", "pressure", ",", "p", "->", "curtime", ")", ";", "}", "else", "if", "(", "ok", "==", "GP_STROKEADD_INVALID", ")", "{", "BKE_report", "(", "op", "->", "reports", ",", "RPT_ERROR", ",", "\"", "\"", ")", ";", "p", "->", "status", "=", "GP_STATUS_ERROR", ";", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "return", ";", "}", "p", "->", "mvalo", "[", "0", "]", "=", "p", "->", "mval", "[", "0", "]", ";", "p", "->", "mvalo", "[", "1", "]", "=", "p", "->", "mval", "[", "1", "]", ";", "p", "->", "opressure", "=", "p", "->", "pressure", ";", "p", "->", "ocurtime", "=", "p", "->", "curtime", ";", "}", "}" ]
create a new stroke point at the point indicated by the painting context
[ "create", "a", "new", "stroke", "point", "at", "the", "point", "indicated", "by", "the", "painting", "context" ]
[ "/* handle drawing/erasing -> test for erasing first */", "/* do 'live' erasing now */", "/* store used values */", "/* Only add current point to buffer if mouse moved\n * (even though we got an event, it might be just noise). */", "/* try to add point */", "/* handle errors while adding point */", "/* finish off old stroke */", "/* And start a new one!!! Else, projection errors! */", "/* start a new stroke, starting from previous point */", "/* XXX Must manually reset inittime... */", "/* XXX We only need to reuse previous point if overflow! */", "/* the painting operation cannot continue... */", "/* store used values */" ]
[ { "param": "op", "type": "wmOperator" }, { "param": "p", "type": "tGPsdata" }, { "param": "depsgraph", "type": "Depsgraph" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "op", "type": "wmOperator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p", "type": "tGPsdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "depsgraph", "type": "Depsgraph", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7a10547f35c176d2f16e3698d84048ee42d0971c
DemonRem/blender
source/blender/editors/gpencil/annotate_paint.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_draw_invoke
int
static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Object *ob = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); tGPsdata *p = NULL; /* support for tablets eraser pen */ if (gpencil_is_tablet_eraser_active(event)) { RNA_enum_set(op->ptr, "mode", GP_PAINTMODE_ERASER); } /* if try to do annotations with a gp object selected, first * unselect the object to avoid conflicts. * The solution is not perfect but we can keep running the annotations while * found a better solution. */ if (sa && sa->spacetype == SPACE_VIEW3D) { if ((ob != NULL) && (ob->type == OB_GPENCIL)) { ob->mode = OB_MODE_OBJECT; bGPdata *gpd = (bGPdata *)ob->data; ED_gpencil_setup_modes(C, gpd, 0); DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); ViewLayer *view_layer = CTX_data_view_layer(C); BKE_view_layer_base_deselect_all(view_layer); view_layer->basact = NULL; DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } if (G.debug & G_DEBUG) { printf("GPencil - Starting Drawing\n"); } /* try to initialize context data needed while drawing */ if (!gpencil_draw_init(C, op, event)) { if (op->customdata) { MEM_freeN(op->customdata); } if (G.debug & G_DEBUG) { printf("\tGP - no valid data\n"); } return OPERATOR_CANCELLED; } else { p = op->customdata; } /* if empty erase capture and finish */ if (p->status == GP_STATUS_CAPTURE) { gpencil_draw_exit(C, op); BKE_report(op->reports, RPT_ERROR, "Nothing to erase"); return OPERATOR_FINISHED; } /* TODO: set any additional settings that we can take from the events? * TODO? if tablet is erasing, force eraser to be on? */ /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, true); } /* set cursor * NOTE: This may change later (i.e. intentionally via brush toggle, * or unintentionally if the user scrolls outside the area)... */ gpencil_draw_cursor_set(p); /* only start drawing immediately if we're allowed to do so... */ if (RNA_boolean_get(op->ptr, "wait_for_input") == false) { /* hotkey invoked - start drawing */ /* printf("\tGP - set first spot\n"); */ p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { /* toolbar invoked - don't start drawing yet... */ /* printf("\tGP - hotkey invoked... waiting for click-drag\n"); */ op->flag |= OP_IS_MODAL_CURSOR_REGION; } WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; }
/* start of interactive drawing part of operator */
start of interactive drawing part of operator
[ "start", "of", "interactive", "drawing", "part", "of", "operator" ]
static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Object *ob = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); tGPsdata *p = NULL; if (gpencil_is_tablet_eraser_active(event)) { RNA_enum_set(op->ptr, "mode", GP_PAINTMODE_ERASER); } if (sa && sa->spacetype == SPACE_VIEW3D) { if ((ob != NULL) && (ob->type == OB_GPENCIL)) { ob->mode = OB_MODE_OBJECT; bGPdata *gpd = (bGPdata *)ob->data; ED_gpencil_setup_modes(C, gpd, 0); DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE); ViewLayer *view_layer = CTX_data_view_layer(C); BKE_view_layer_base_deselect_all(view_layer); view_layer->basact = NULL; DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } if (G.debug & G_DEBUG) { printf("GPencil - Starting Drawing\n"); } if (!gpencil_draw_init(C, op, event)) { if (op->customdata) { MEM_freeN(op->customdata); } if (G.debug & G_DEBUG) { printf("\tGP - no valid data\n"); } return OPERATOR_CANCELLED; } else { p = op->customdata; } if (p->status == GP_STATUS_CAPTURE) { gpencil_draw_exit(C, op); BKE_report(op->reports, RPT_ERROR, "Nothing to erase"); return OPERATOR_FINISHED; } if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, true); } gpencil_draw_cursor_set(p); if (RNA_boolean_get(op->ptr, "wait_for_input") == false) { p->status = GP_STATUS_PAINTING; annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { op->flag |= OP_IS_MODAL_CURSOR_REGION; } WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; }
[ "static", "int", "gpencil_draw_invoke", "(", "bContext", "*", "C", ",", "wmOperator", "*", "op", ",", "const", "wmEvent", "*", "event", ")", "{", "Object", "*", "ob", "=", "CTX_data_active_object", "(", "C", ")", ";", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "Scene", "*", "scene", "=", "CTX_data_scene", "(", "C", ")", ";", "tGPsdata", "*", "p", "=", "NULL", ";", "if", "(", "gpencil_is_tablet_eraser_active", "(", "event", ")", ")", "{", "RNA_enum_set", "(", "op", "->", "ptr", ",", "\"", "\"", ",", "GP_PAINTMODE_ERASER", ")", ";", "}", "if", "(", "sa", "&&", "sa", "->", "spacetype", "==", "SPACE_VIEW3D", ")", "{", "if", "(", "(", "ob", "!=", "NULL", ")", "&&", "(", "ob", "->", "type", "==", "OB_GPENCIL", ")", ")", "{", "ob", "->", "mode", "=", "OB_MODE_OBJECT", ";", "bGPdata", "*", "gpd", "=", "(", "bGPdata", "*", ")", "ob", "->", "data", ";", "ED_gpencil_setup_modes", "(", "C", ",", "gpd", ",", "0", ")", ";", "DEG_id_tag_update", "(", "&", "gpd", "->", "id", ",", "ID_RECALC_COPY_ON_WRITE", ")", ";", "ViewLayer", "*", "view_layer", "=", "CTX_data_view_layer", "(", "C", ")", ";", "BKE_view_layer_base_deselect_all", "(", "view_layer", ")", ";", "view_layer", "->", "basact", "=", "NULL", ";", "DEG_id_tag_update", "(", "&", "scene", "->", "id", ",", "ID_RECALC_SELECT", ")", ";", "WM_event_add_notifier", "(", "C", ",", "NC_SCENE", "|", "ND_OB_SELECT", ",", "scene", ")", ";", "}", "}", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\n", "\"", ")", ";", "}", "if", "(", "!", "gpencil_draw_init", "(", "C", ",", "op", ",", "event", ")", ")", "{", "if", "(", "op", "->", "customdata", ")", "{", "MEM_freeN", "(", "op", "->", "customdata", ")", ";", "}", "if", "(", "G", ".", "debug", "&", "G_DEBUG", ")", "{", "printf", "(", "\"", "\\t", "\\n", "\"", ")", ";", "}", "return", "OPERATOR_CANCELLED", ";", "}", "else", "{", "p", "=", "op", "->", "customdata", ";", "}", "if", "(", "p", "->", "status", "==", "GP_STATUS_CAPTURE", ")", "{", "gpencil_draw_exit", "(", "C", ",", "op", ")", ";", "BKE_report", "(", "op", "->", "reports", ",", "RPT_ERROR", ",", "\"", "\"", ")", ";", "return", "OPERATOR_FINISHED", ";", "}", "if", "(", "p", "->", "paintmode", "==", "GP_PAINTMODE_ERASER", ")", "{", "gpencil_draw_toggle_eraser_cursor", "(", "C", ",", "p", ",", "true", ")", ";", "}", "gpencil_draw_cursor_set", "(", "p", ")", ";", "if", "(", "RNA_boolean_get", "(", "op", "->", "ptr", ",", "\"", "\"", ")", "==", "false", ")", "{", "p", "->", "status", "=", "GP_STATUS_PAINTING", ";", "annotation_draw_apply_event", "(", "op", ",", "event", ",", "CTX_data_ensure_evaluated_depsgraph", "(", "C", ")", ",", "0.0f", ",", "0.0f", ")", ";", "op", "->", "flag", "|=", "OP_IS_MODAL_CURSOR_REGION", ";", "}", "else", "{", "op", "->", "flag", "|=", "OP_IS_MODAL_CURSOR_REGION", ";", "}", "WM_event_add_notifier", "(", "C", ",", "NC_GPENCIL", "|", "NA_EDITED", ",", "NULL", ")", ";", "WM_event_add_modal_handler", "(", "C", ",", "op", ")", ";", "return", "OPERATOR_RUNNING_MODAL", ";", "}" ]
start of interactive drawing part of operator
[ "start", "of", "interactive", "drawing", "part", "of", "operator" ]
[ "/* support for tablets eraser pen */", "/* if try to do annotations with a gp object selected, first\n * unselect the object to avoid conflicts.\n * The solution is not perfect but we can keep running the annotations while\n * found a better solution.\n */", "/* try to initialize context data needed while drawing */", "/* if empty erase capture and finish */", "/* TODO: set any additional settings that we can take from the events?\n * TODO? if tablet is erasing, force eraser to be on? */", "/* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */", "/* if eraser is on, draw radial aid */", "/* set cursor\n * NOTE: This may change later (i.e. intentionally via brush toggle,\n * or unintentionally if the user scrolls outside the area)...\n */", "/* only start drawing immediately if we're allowed to do so... */", "/* hotkey invoked - start drawing */", "/* printf(\"\\tGP - set first spot\\n\"); */", "/* handle the initial drawing - i.e. for just doing a simple dot */", "/* toolbar invoked - don't start drawing yet... */", "/* printf(\"\\tGP - hotkey invoked... waiting for click-drag\\n\"); */", "/* add a modal handler for this operator, so that we can then draw continuous strokes */" ]
[ { "param": "C", "type": "bContext" }, { "param": "op", "type": "wmOperator" }, { "param": "event", "type": "wmEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "wmOperator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "wmEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
680607116813c27c1513e0f2e61f2bfc4dbcba5c
DemonRem/blender
source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
deformStroke
void
static void deformStroke(GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), Object *ob, bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps) { SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md; const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->materialname, mmd->pass_index, mmd->layer_pass, 3, gpl, gps, mmd->flag & GP_SMOOTH_INVERT_LAYER, mmd->flag & GP_SMOOTH_INVERT_PASS, mmd->flag & GP_SMOOTH_INVERT_LAYERPASS, mmd->flag & GP_SMOOTH_INVERT_MATERIAL)) { return; } /* smooth stroke */ if (mmd->factor > 0.0f) { for (int r = 0; r < mmd->step; r++) { for (int i = 0; i < gps->totpoints; i++) { MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL; /* verify vertex group */ const float weight = get_modifier_point_weight( dvert, (mmd->flag & GP_SMOOTH_INVERT_VGROUP) != 0, def_nr); if (weight < 0.0f) { continue; } const float val = mmd->factor * weight; /* perform smoothing */ if (mmd->flag & GP_SMOOTH_MOD_LOCATION) { BKE_gpencil_smooth_stroke(gps, i, val); } if (mmd->flag & GP_SMOOTH_MOD_STRENGTH) { BKE_gpencil_smooth_stroke_strength(gps, i, val); } if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS) && (val > 0.0f)) { /* thickness need to repeat process several times */ for (int r2 = 0; r2 < r * 10; r2++) { BKE_gpencil_smooth_stroke_thickness(gps, i, val); } } if (mmd->flag & GP_SMOOTH_MOD_UV) { BKE_gpencil_smooth_stroke_uv(gps, i, val); } } } } }
/* aply smooth effect based on stroke direction */
aply smooth effect based on stroke direction
[ "aply", "smooth", "effect", "based", "on", "stroke", "direction" ]
static void deformStroke(GpencilModifierData *md, Depsgraph *UNUSED(depsgraph), Object *ob, bGPDlayer *gpl, bGPDframe *UNUSED(gpf), bGPDstroke *gps) { SmoothGpencilModifierData *mmd = (SmoothGpencilModifierData *)md; const int def_nr = defgroup_name_index(ob, mmd->vgname); if (!is_stroke_affected_by_modifier(ob, mmd->layername, mmd->materialname, mmd->pass_index, mmd->layer_pass, 3, gpl, gps, mmd->flag & GP_SMOOTH_INVERT_LAYER, mmd->flag & GP_SMOOTH_INVERT_PASS, mmd->flag & GP_SMOOTH_INVERT_LAYERPASS, mmd->flag & GP_SMOOTH_INVERT_MATERIAL)) { return; } if (mmd->factor > 0.0f) { for (int r = 0; r < mmd->step; r++) { for (int i = 0; i < gps->totpoints; i++) { MDeformVert *dvert = gps->dvert != NULL ? &gps->dvert[i] : NULL; const float weight = get_modifier_point_weight( dvert, (mmd->flag & GP_SMOOTH_INVERT_VGROUP) != 0, def_nr); if (weight < 0.0f) { continue; } const float val = mmd->factor * weight; if (mmd->flag & GP_SMOOTH_MOD_LOCATION) { BKE_gpencil_smooth_stroke(gps, i, val); } if (mmd->flag & GP_SMOOTH_MOD_STRENGTH) { BKE_gpencil_smooth_stroke_strength(gps, i, val); } if ((mmd->flag & GP_SMOOTH_MOD_THICKNESS) && (val > 0.0f)) { for (int r2 = 0; r2 < r * 10; r2++) { BKE_gpencil_smooth_stroke_thickness(gps, i, val); } } if (mmd->flag & GP_SMOOTH_MOD_UV) { BKE_gpencil_smooth_stroke_uv(gps, i, val); } } } } }
[ "static", "void", "deformStroke", "(", "GpencilModifierData", "*", "md", ",", "Depsgraph", "*", "UNUSED", "(", "depsgraph", ")", ",", "Object", "*", "ob", ",", "bGPDlayer", "*", "gpl", ",", "bGPDframe", "*", "UNUSED", "(", "gpf", ")", ",", "bGPDstroke", "*", "gps", ")", "{", "SmoothGpencilModifierData", "*", "mmd", "=", "(", "SmoothGpencilModifierData", "*", ")", "md", ";", "const", "int", "def_nr", "=", "defgroup_name_index", "(", "ob", ",", "mmd", "->", "vgname", ")", ";", "if", "(", "!", "is_stroke_affected_by_modifier", "(", "ob", ",", "mmd", "->", "layername", ",", "mmd", "->", "materialname", ",", "mmd", "->", "pass_index", ",", "mmd", "->", "layer_pass", ",", "3", ",", "gpl", ",", "gps", ",", "mmd", "->", "flag", "&", "GP_SMOOTH_INVERT_LAYER", ",", "mmd", "->", "flag", "&", "GP_SMOOTH_INVERT_PASS", ",", "mmd", "->", "flag", "&", "GP_SMOOTH_INVERT_LAYERPASS", ",", "mmd", "->", "flag", "&", "GP_SMOOTH_INVERT_MATERIAL", ")", ")", "{", "return", ";", "}", "if", "(", "mmd", "->", "factor", ">", "0.0f", ")", "{", "for", "(", "int", "r", "=", "0", ";", "r", "<", "mmd", "->", "step", ";", "r", "++", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "gps", "->", "totpoints", ";", "i", "++", ")", "{", "MDeformVert", "*", "dvert", "=", "gps", "->", "dvert", "!=", "NULL", "?", "&", "gps", "->", "dvert", "[", "i", "]", ":", "NULL", ";", "const", "float", "weight", "=", "get_modifier_point_weight", "(", "dvert", ",", "(", "mmd", "->", "flag", "&", "GP_SMOOTH_INVERT_VGROUP", ")", "!=", "0", ",", "def_nr", ")", ";", "if", "(", "weight", "<", "0.0f", ")", "{", "continue", ";", "}", "const", "float", "val", "=", "mmd", "->", "factor", "*", "weight", ";", "if", "(", "mmd", "->", "flag", "&", "GP_SMOOTH_MOD_LOCATION", ")", "{", "BKE_gpencil_smooth_stroke", "(", "gps", ",", "i", ",", "val", ")", ";", "}", "if", "(", "mmd", "->", "flag", "&", "GP_SMOOTH_MOD_STRENGTH", ")", "{", "BKE_gpencil_smooth_stroke_strength", "(", "gps", ",", "i", ",", "val", ")", ";", "}", "if", "(", "(", "mmd", "->", "flag", "&", "GP_SMOOTH_MOD_THICKNESS", ")", "&&", "(", "val", ">", "0.0f", ")", ")", "{", "for", "(", "int", "r2", "=", "0", ";", "r2", "<", "r", "*", "10", ";", "r2", "++", ")", "{", "BKE_gpencil_smooth_stroke_thickness", "(", "gps", ",", "i", ",", "val", ")", ";", "}", "}", "if", "(", "mmd", "->", "flag", "&", "GP_SMOOTH_MOD_UV", ")", "{", "BKE_gpencil_smooth_stroke_uv", "(", "gps", ",", "i", ",", "val", ")", ";", "}", "}", "}", "}", "}" ]
aply smooth effect based on stroke direction
[ "aply", "smooth", "effect", "based", "on", "stroke", "direction" ]
[ "/* smooth stroke */", "/* verify vertex group */", "/* perform smoothing */", "/* thickness need to repeat process several times */" ]
[ { "param": "md", "type": "GpencilModifierData" }, { "param": "UNUSED", "type": "bGPDframe" }, { "param": "ob", "type": "Object" }, { "param": "gpl", "type": "bGPDlayer" }, { "param": "gps", "type": "bGPDstroke" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "md", "type": "GpencilModifierData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "UNUSED", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpl", "type": "bGPDlayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_free_tree_element
void
void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree) { BLI_assert(BLI_findindex(parent_subtree, element) > -1); BLI_remlink(parent_subtree, element); outliner_free_tree(&element->subtree); if (element->flag & TE_FREE_NAME) { MEM_freeN((void *)element->name); } MEM_freeN(element); }
/** * Free \a element and its sub-tree and remove its link in \a parent_subtree. * * \note Does not remove the #TreeStoreElem of \a element! * \param parent_subtree: Sub-tree of the parent element, so the list containing \a element. */
Free \a element and its sub-tree and remove its link in \a parent_subtree. \note Does not remove the #TreeStoreElem of \a element. \param parent_subtree: Sub-tree of the parent element, so the list containing \a element.
[ "Free", "\\", "a", "element", "and", "its", "sub", "-", "tree", "and", "remove", "its", "link", "in", "\\", "a", "parent_subtree", ".", "\\", "note", "Does", "not", "remove", "the", "#TreeStoreElem", "of", "\\", "a", "element", ".", "\\", "param", "parent_subtree", ":", "Sub", "-", "tree", "of", "the", "parent", "element", "so", "the", "list", "containing", "\\", "a", "element", "." ]
void outliner_free_tree_element(TreeElement *element, ListBase *parent_subtree) { BLI_assert(BLI_findindex(parent_subtree, element) > -1); BLI_remlink(parent_subtree, element); outliner_free_tree(&element->subtree); if (element->flag & TE_FREE_NAME) { MEM_freeN((void *)element->name); } MEM_freeN(element); }
[ "void", "outliner_free_tree_element", "(", "TreeElement", "*", "element", ",", "ListBase", "*", "parent_subtree", ")", "{", "BLI_assert", "(", "BLI_findindex", "(", "parent_subtree", ",", "element", ")", ">", "-1", ")", ";", "BLI_remlink", "(", "parent_subtree", ",", "element", ")", ";", "outliner_free_tree", "(", "&", "element", "->", "subtree", ")", ";", "if", "(", "element", "->", "flag", "&", "TE_FREE_NAME", ")", "{", "MEM_freeN", "(", "(", "void", "*", ")", "element", "->", "name", ")", ";", "}", "MEM_freeN", "(", "element", ")", ";", "}" ]
Free \a element and its sub-tree and remove its link in \a parent_subtree.
[ "Free", "\\", "a", "element", "and", "its", "sub", "-", "tree", "and", "remove", "its", "link", "in", "\\", "a", "parent_subtree", "." ]
[]
[ { "param": "element", "type": "TreeElement" }, { "param": "parent_subtree", "type": "ListBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "element", "type": "TreeElement", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent_subtree", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_add_bone
void
static void outliner_add_bone( SpaceOutliner *soops, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a) { TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); (*a)++; te->name = curBone->name; te->directdata = curBone; for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } }
/* special handling of hierarchical non-lib data */
special handling of hierarchical non-lib data
[ "special", "handling", "of", "hierarchical", "non", "-", "lib", "data" ]
static void outliner_add_bone( SpaceOutliner *soops, ListBase *lb, ID *id, Bone *curBone, TreeElement *parent, int *a) { TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); (*a)++; te->name = curBone->name; te->directdata = curBone; for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } }
[ "static", "void", "outliner_add_bone", "(", "SpaceOutliner", "*", "soops", ",", "ListBase", "*", "lb", ",", "ID", "*", "id", ",", "Bone", "*", "curBone", ",", "TreeElement", "*", "parent", ",", "int", "*", "a", ")", "{", "TreeElement", "*", "te", "=", "outliner_add_element", "(", "soops", ",", "lb", ",", "id", ",", "parent", ",", "TSE_BONE", ",", "*", "a", ")", ";", "(", "*", "a", ")", "++", ";", "te", "->", "name", "=", "curBone", "->", "name", ";", "te", "->", "directdata", "=", "curBone", ";", "for", "(", "curBone", "=", "curBone", "->", "childbase", ".", "first", ";", "curBone", ";", "curBone", "=", "curBone", "->", "next", ")", "{", "outliner_add_bone", "(", "soops", ",", "&", "te", "->", "subtree", ",", "id", ",", "curBone", ",", "te", ",", "a", ")", ";", "}", "}" ]
special handling of hierarchical non-lib data
[ "special", "handling", "of", "hierarchical", "non", "-", "lib", "data" ]
[]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "lb", "type": "ListBase" }, { "param": "id", "type": "ID" }, { "param": "curBone", "type": "Bone" }, { "param": "parent", "type": "TreeElement" }, { "param": "a", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lb", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id", "type": "ID", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "curBone", "type": "Bone", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parent", "type": "TreeElement", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
need_add_seq_dup
int
static int need_add_seq_dup(Sequence *seq) { Sequence *p; if ((!seq->strip) || (!seq->strip->stripdata)) { return 1; } /* * First check backward, if we found a duplicate * sequence before this, don't need it, just return. */ p = seq->prev; while (p) { if ((!p->strip) || (!p->strip->stripdata)) { p = p->prev; continue; } if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { return 2; } p = p->prev; } p = seq->next; while (p) { if ((!p->strip) || (!p->strip->stripdata)) { p = p->next; continue; } if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { return 0; } p = p->next; } return (1); }
/* Helped function to put duplicate sequence in the same tree. */
Helped function to put duplicate sequence in the same tree.
[ "Helped", "function", "to", "put", "duplicate", "sequence", "in", "the", "same", "tree", "." ]
static int need_add_seq_dup(Sequence *seq) { Sequence *p; if ((!seq->strip) || (!seq->strip->stripdata)) { return 1; } p = seq->prev; while (p) { if ((!p->strip) || (!p->strip->stripdata)) { p = p->prev; continue; } if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { return 2; } p = p->prev; } p = seq->next; while (p) { if ((!p->strip) || (!p->strip->stripdata)) { p = p->next; continue; } if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { return 0; } p = p->next; } return (1); }
[ "static", "int", "need_add_seq_dup", "(", "Sequence", "*", "seq", ")", "{", "Sequence", "*", "p", ";", "if", "(", "(", "!", "seq", "->", "strip", ")", "||", "(", "!", "seq", "->", "strip", "->", "stripdata", ")", ")", "{", "return", "1", ";", "}", "p", "=", "seq", "->", "prev", ";", "while", "(", "p", ")", "{", "if", "(", "(", "!", "p", "->", "strip", ")", "||", "(", "!", "p", "->", "strip", "->", "stripdata", ")", ")", "{", "p", "=", "p", "->", "prev", ";", "continue", ";", "}", "if", "(", "STREQ", "(", "p", "->", "strip", "->", "stripdata", "->", "name", ",", "seq", "->", "strip", "->", "stripdata", "->", "name", ")", ")", "{", "return", "2", ";", "}", "p", "=", "p", "->", "prev", ";", "}", "p", "=", "seq", "->", "next", ";", "while", "(", "p", ")", "{", "if", "(", "(", "!", "p", "->", "strip", ")", "||", "(", "!", "p", "->", "strip", "->", "stripdata", ")", ")", "{", "p", "=", "p", "->", "next", ";", "continue", ";", "}", "if", "(", "STREQ", "(", "p", "->", "strip", "->", "stripdata", "->", "name", ",", "seq", "->", "strip", "->", "stripdata", "->", "name", ")", ")", "{", "return", "0", ";", "}", "p", "=", "p", "->", "next", ";", "}", "return", "(", "1", ")", ";", "}" ]
Helped function to put duplicate sequence in the same tree.
[ "Helped", "function", "to", "put", "duplicate", "sequence", "in", "the", "same", "tree", "." ]
[ "/*\n * First check backward, if we found a duplicate\n * sequence before this, don't need it, just return.\n */" ]
[ { "param": "seq", "type": "Sequence" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seq", "type": "Sequence", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_make_object_parent_hierarchy
void
static void outliner_make_object_parent_hierarchy(ListBase *lb) { TreeElement *te, *ten, *tep; TreeStoreElem *tselem; /* build hierarchy */ // XXX also, set extents here... te = lb->first; while (te) { ten = te->next; tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); te->parent = tep; } } te = ten; } }
/* make sure elements are correctly nested */
make sure elements are correctly nested
[ "make", "sure", "elements", "are", "correctly", "nested" ]
static void outliner_make_object_parent_hierarchy(ListBase *lb) { TreeElement *te, *ten, *tep; TreeStoreElem *tselem; te = lb->first; while (te) { ten = te->next; tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); te->parent = tep; } } te = ten; } }
[ "static", "void", "outliner_make_object_parent_hierarchy", "(", "ListBase", "*", "lb", ")", "{", "TreeElement", "*", "te", ",", "*", "ten", ",", "*", "tep", ";", "TreeStoreElem", "*", "tselem", ";", "te", "=", "lb", "->", "first", ";", "while", "(", "te", ")", "{", "ten", "=", "te", "->", "next", ";", "tselem", "=", "TREESTORE", "(", "te", ")", ";", "if", "(", "tselem", "->", "type", "==", "0", "&&", "te", "->", "idcode", "==", "ID_OB", ")", "{", "Object", "*", "ob", "=", "(", "Object", "*", ")", "tselem", "->", "id", ";", "if", "(", "ob", "->", "parent", "&&", "ob", "->", "parent", "->", "id", ".", "newid", ")", "{", "BLI_remlink", "(", "lb", ",", "te", ")", ";", "tep", "=", "(", "TreeElement", "*", ")", "ob", "->", "parent", "->", "id", ".", "newid", ";", "BLI_addtail", "(", "&", "tep", "->", "subtree", ",", "te", ")", ";", "te", "->", "parent", "=", "tep", ";", "}", "}", "te", "=", "ten", ";", "}", "}" ]
make sure elements are correctly nested
[ "make", "sure", "elements", "are", "correctly", "nested" ]
[ "/* build hierarchy */", "// XXX also, set extents here..." ]
[ { "param": "lb", "type": "ListBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lb", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_make_object_parent_hierarchy_collections
void
static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops, GHash *object_tree_elements_hash) { GHashIterator gh_iter; GHASH_ITER (gh_iter, object_tree_elements_hash) { Object *child = BLI_ghashIterator_getKey(&gh_iter); if (child->parent == NULL) { continue; } ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter); ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent); if (parent_ob_tree_elements == NULL) { continue; } for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) { TreeElement *parent_ob_tree_element = link->data; TreeElement *parent_ob_collection_tree_element = NULL; bool found = false; /* We always want to remove the child from the direct collection its parent is nested under. * This is particularly important when dealing with multi-level nesting (grandchildren). */ parent_ob_collection_tree_element = parent_ob_tree_element->parent; while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, TSE_VIEW_COLLECTION_BASE, TSE_LAYER_COLLECTION)) { parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; } for (LinkData *link_iter = child_ob_tree_elements->first; link_iter; link_iter = link_iter->next) { TreeElement *child_ob_tree_element = link_iter->data; if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { /* Move from the collection subtree into the parent object subtree. */ BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element); BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element); child_ob_tree_element->parent = parent_ob_tree_element; found = true; break; } } if (!found) { /* We add the child in the tree even if it is not in the collection. * We deliberately clear its sub-tree though, to make it less prominent. */ TreeElement *child_ob_tree_element = outliner_add_element( soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0); outliner_free_tree(&child_ob_tree_element->subtree); child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION; BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element)); } } } }
/** * For all objects in the tree, lookup the parent in this map, * and move or add tree elements as needed. */
For all objects in the tree, lookup the parent in this map, and move or add tree elements as needed.
[ "For", "all", "objects", "in", "the", "tree", "lookup", "the", "parent", "in", "this", "map", "and", "move", "or", "add", "tree", "elements", "as", "needed", "." ]
static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soops, GHash *object_tree_elements_hash) { GHashIterator gh_iter; GHASH_ITER (gh_iter, object_tree_elements_hash) { Object *child = BLI_ghashIterator_getKey(&gh_iter); if (child->parent == NULL) { continue; } ListBase *child_ob_tree_elements = BLI_ghashIterator_getValue(&gh_iter); ListBase *parent_ob_tree_elements = BLI_ghash_lookup(object_tree_elements_hash, child->parent); if (parent_ob_tree_elements == NULL) { continue; } for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) { TreeElement *parent_ob_tree_element = link->data; TreeElement *parent_ob_collection_tree_element = NULL; bool found = false; parent_ob_collection_tree_element = parent_ob_tree_element->parent; while (!ELEM(TREESTORE(parent_ob_collection_tree_element)->type, TSE_VIEW_COLLECTION_BASE, TSE_LAYER_COLLECTION)) { parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent; } for (LinkData *link_iter = child_ob_tree_elements->first; link_iter; link_iter = link_iter->next) { TreeElement *child_ob_tree_element = link_iter->data; if (child_ob_tree_element->parent == parent_ob_collection_tree_element) { BLI_remlink(&parent_ob_collection_tree_element->subtree, child_ob_tree_element); BLI_addtail(&parent_ob_tree_element->subtree, child_ob_tree_element); child_ob_tree_element->parent = parent_ob_tree_element; found = true; break; } } if (!found) { TreeElement *child_ob_tree_element = outliner_add_element( soops, &parent_ob_tree_element->subtree, child, parent_ob_tree_element, 0, 0); outliner_free_tree(&child_ob_tree_element->subtree); child_ob_tree_element->flag |= TE_CHILD_NOT_IN_COLLECTION; BLI_addtail(child_ob_tree_elements, BLI_genericNodeN(child_ob_tree_element)); } } } }
[ "static", "void", "outliner_make_object_parent_hierarchy_collections", "(", "SpaceOutliner", "*", "soops", ",", "GHash", "*", "object_tree_elements_hash", ")", "{", "GHashIterator", "gh_iter", ";", "GHASH_ITER", "(", "gh_iter", ",", "object_tree_elements_hash", ")", "", "{", "Object", "*", "child", "=", "BLI_ghashIterator_getKey", "(", "&", "gh_iter", ")", ";", "if", "(", "child", "->", "parent", "==", "NULL", ")", "{", "continue", ";", "}", "ListBase", "*", "child_ob_tree_elements", "=", "BLI_ghashIterator_getValue", "(", "&", "gh_iter", ")", ";", "ListBase", "*", "parent_ob_tree_elements", "=", "BLI_ghash_lookup", "(", "object_tree_elements_hash", ",", "child", "->", "parent", ")", ";", "if", "(", "parent_ob_tree_elements", "==", "NULL", ")", "{", "continue", ";", "}", "for", "(", "LinkData", "*", "link", "=", "parent_ob_tree_elements", "->", "first", ";", "link", ";", "link", "=", "link", "->", "next", ")", "{", "TreeElement", "*", "parent_ob_tree_element", "=", "link", "->", "data", ";", "TreeElement", "*", "parent_ob_collection_tree_element", "=", "NULL", ";", "bool", "found", "=", "false", ";", "parent_ob_collection_tree_element", "=", "parent_ob_tree_element", "->", "parent", ";", "while", "(", "!", "ELEM", "(", "TREESTORE", "(", "parent_ob_collection_tree_element", ")", "->", "type", ",", "TSE_VIEW_COLLECTION_BASE", ",", "TSE_LAYER_COLLECTION", ")", ")", "{", "parent_ob_collection_tree_element", "=", "parent_ob_collection_tree_element", "->", "parent", ";", "}", "for", "(", "LinkData", "*", "link_iter", "=", "child_ob_tree_elements", "->", "first", ";", "link_iter", ";", "link_iter", "=", "link_iter", "->", "next", ")", "{", "TreeElement", "*", "child_ob_tree_element", "=", "link_iter", "->", "data", ";", "if", "(", "child_ob_tree_element", "->", "parent", "==", "parent_ob_collection_tree_element", ")", "{", "BLI_remlink", "(", "&", "parent_ob_collection_tree_element", "->", "subtree", ",", "child_ob_tree_element", ")", ";", "BLI_addtail", "(", "&", "parent_ob_tree_element", "->", "subtree", ",", "child_ob_tree_element", ")", ";", "child_ob_tree_element", "->", "parent", "=", "parent_ob_tree_element", ";", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "found", ")", "{", "TreeElement", "*", "child_ob_tree_element", "=", "outliner_add_element", "(", "soops", ",", "&", "parent_ob_tree_element", "->", "subtree", ",", "child", ",", "parent_ob_tree_element", ",", "0", ",", "0", ")", ";", "outliner_free_tree", "(", "&", "child_ob_tree_element", "->", "subtree", ")", ";", "child_ob_tree_element", "->", "flag", "|=", "TE_CHILD_NOT_IN_COLLECTION", ";", "BLI_addtail", "(", "child_ob_tree_elements", ",", "BLI_genericNodeN", "(", "child_ob_tree_element", ")", ")", ";", "}", "}", "}", "}" ]
For all objects in the tree, lookup the parent in this map, and move or add tree elements as needed.
[ "For", "all", "objects", "in", "the", "tree", "lookup", "the", "parent", "in", "this", "map", "and", "move", "or", "add", "tree", "elements", "as", "needed", "." ]
[ "/* We always want to remove the child from the direct collection its parent is nested under.\n * This is particularly important when dealing with multi-level nesting (grandchildren). */", "/* Move from the collection subtree into the parent object subtree. */", "/* We add the child in the tree even if it is not in the collection.\n * We deliberately clear its sub-tree though, to make it less prominent. */" ]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "object_tree_elements_hash", "type": "GHash" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "object_tree_elements_hash", "type": "GHash", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_object_tree_elements_lookup_create_recursive
void
static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, TreeElement *te_parent) { for (TreeElement *te = te_parent->subtree.first; te; te = te->next) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == TSE_LAYER_COLLECTION) { outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); } else if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob); if (tree_elements == NULL) { tree_elements = MEM_callocN(sizeof(ListBase), __func__); BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements); } BLI_addtail(tree_elements, BLI_genericNodeN(te)); outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); } } }
/** * Build a map from Object* to a list of TreeElement* matching the object. */
Build a map from Object* to a list of TreeElement* matching the object.
[ "Build", "a", "map", "from", "Object", "*", "to", "a", "list", "of", "TreeElement", "*", "matching", "the", "object", "." ]
static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash, TreeElement *te_parent) { for (TreeElement *te = te_parent->subtree.first; te; te = te->next) { TreeStoreElem *tselem = TREESTORE(te); if (tselem->type == TSE_LAYER_COLLECTION) { outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); } else if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; ListBase *tree_elements = BLI_ghash_lookup(object_tree_elements_hash, ob); if (tree_elements == NULL) { tree_elements = MEM_callocN(sizeof(ListBase), __func__); BLI_ghash_insert(object_tree_elements_hash, ob, tree_elements); } BLI_addtail(tree_elements, BLI_genericNodeN(te)); outliner_object_tree_elements_lookup_create_recursive(object_tree_elements_hash, te); } } }
[ "static", "void", "outliner_object_tree_elements_lookup_create_recursive", "(", "GHash", "*", "object_tree_elements_hash", ",", "TreeElement", "*", "te_parent", ")", "{", "for", "(", "TreeElement", "*", "te", "=", "te_parent", "->", "subtree", ".", "first", ";", "te", ";", "te", "=", "te", "->", "next", ")", "{", "TreeStoreElem", "*", "tselem", "=", "TREESTORE", "(", "te", ")", ";", "if", "(", "tselem", "->", "type", "==", "TSE_LAYER_COLLECTION", ")", "{", "outliner_object_tree_elements_lookup_create_recursive", "(", "object_tree_elements_hash", ",", "te", ")", ";", "}", "else", "if", "(", "tselem", "->", "type", "==", "0", "&&", "te", "->", "idcode", "==", "ID_OB", ")", "{", "Object", "*", "ob", "=", "(", "Object", "*", ")", "tselem", "->", "id", ";", "ListBase", "*", "tree_elements", "=", "BLI_ghash_lookup", "(", "object_tree_elements_hash", ",", "ob", ")", ";", "if", "(", "tree_elements", "==", "NULL", ")", "{", "tree_elements", "=", "MEM_callocN", "(", "sizeof", "(", "ListBase", ")", ",", "__func__", ")", ";", "BLI_ghash_insert", "(", "object_tree_elements_hash", ",", "ob", ",", "tree_elements", ")", ";", "}", "BLI_addtail", "(", "tree_elements", ",", "BLI_genericNodeN", "(", "te", ")", ")", ";", "outliner_object_tree_elements_lookup_create_recursive", "(", "object_tree_elements_hash", ",", "te", ")", ";", "}", "}", "}" ]
Build a map from Object* to a list of TreeElement* matching the object.
[ "Build", "a", "map", "from", "Object", "*", "to", "a", "list", "of", "TreeElement", "*", "matching", "the", "object", "." ]
[]
[ { "param": "object_tree_elements_hash", "type": "GHash" }, { "param": "te_parent", "type": "TreeElement" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "object_tree_elements_hash", "type": "GHash", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "te_parent", "type": "TreeElement", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
treesort_alpha_ob
int
static int treesort_alpha_ob(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; /* first put objects last (hierarchy) */ comp = (x1->idcode == ID_OB); if (x2->idcode == ID_OB) { comp += 2; } if (comp == 1) { return 1; } else if (comp == 2) { return -1; } else if (comp == 3) { /* Among objects first come the ones in the collection, followed by the ones not on it. * This way we can have the dashed lines in a separate style connecting the former. */ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } comp = BLI_strcasecmp_natural(x1->name, x2->name); if (comp > 0) { return 1; } else if (comp < 0) { return -1; } return 0; } return 0; }
/* alphabetical comparator, trying to put objects first */
alphabetical comparator, trying to put objects first
[ "alphabetical", "comparator", "trying", "to", "put", "objects", "first" ]
static int treesort_alpha_ob(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; comp = (x1->idcode == ID_OB); if (x2->idcode == ID_OB) { comp += 2; } if (comp == 1) { return 1; } else if (comp == 2) { return -1; } else if (comp == 3) { if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } comp = BLI_strcasecmp_natural(x1->name, x2->name); if (comp > 0) { return 1; } else if (comp < 0) { return -1; } return 0; } return 0; }
[ "static", "int", "treesort_alpha_ob", "(", "const", "void", "*", "v1", ",", "const", "void", "*", "v2", ")", "{", "const", "tTreeSort", "*", "x1", "=", "v1", ",", "*", "x2", "=", "v2", ";", "int", "comp", ";", "comp", "=", "(", "x1", "->", "idcode", "==", "ID_OB", ")", ";", "if", "(", "x2", "->", "idcode", "==", "ID_OB", ")", "{", "comp", "+=", "2", ";", "}", "if", "(", "comp", "==", "1", ")", "{", "return", "1", ";", "}", "else", "if", "(", "comp", "==", "2", ")", "{", "return", "-1", ";", "}", "else", "if", "(", "comp", "==", "3", ")", "{", "if", "(", "(", "x1", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", "!=", "(", "x2", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", ")", "{", "return", "(", "x1", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", "?", "1", ":", "-1", ";", "}", "comp", "=", "BLI_strcasecmp_natural", "(", "x1", "->", "name", ",", "x2", "->", "name", ")", ";", "if", "(", "comp", ">", "0", ")", "{", "return", "1", ";", "}", "else", "if", "(", "comp", "<", "0", ")", "{", "return", "-1", ";", "}", "return", "0", ";", "}", "return", "0", ";", "}" ]
alphabetical comparator, trying to put objects first
[ "alphabetical", "comparator", "trying", "to", "put", "objects", "first" ]
[ "/* first put objects last (hierarchy) */", "/* Among objects first come the ones in the collection, followed by the ones not on it.\n * This way we can have the dashed lines in a separate style connecting the former. */" ]
[ { "param": "v1", "type": "void" }, { "param": "v2", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
treesort_child_not_in_collection
int
static int treesort_child_not_in_collection(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; /* Among objects first come the ones in the collection, followed by the ones not on it. * This way we can have the dashed lines in a separate style connecting the former. */ if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } return 0; }
/* Move children that are not in the collection to the end of the list. */
Move children that are not in the collection to the end of the list.
[ "Move", "children", "that", "are", "not", "in", "the", "collection", "to", "the", "end", "of", "the", "list", "." ]
static int treesort_child_not_in_collection(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; if ((x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) != (x2->te->flag & TE_CHILD_NOT_IN_COLLECTION)) { return (x1->te->flag & TE_CHILD_NOT_IN_COLLECTION) ? 1 : -1; } return 0; }
[ "static", "int", "treesort_child_not_in_collection", "(", "const", "void", "*", "v1", ",", "const", "void", "*", "v2", ")", "{", "const", "tTreeSort", "*", "x1", "=", "v1", ",", "*", "x2", "=", "v2", ";", "if", "(", "(", "x1", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", "!=", "(", "x2", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", ")", "{", "return", "(", "x1", "->", "te", "->", "flag", "&", "TE_CHILD_NOT_IN_COLLECTION", ")", "?", "1", ":", "-1", ";", "}", "return", "0", ";", "}" ]
Move children that are not in the collection to the end of the list.
[ "Move", "children", "that", "are", "not", "in", "the", "collection", "to", "the", "end", "of", "the", "list", "." ]
[ "/* Among objects first come the ones in the collection, followed by the ones not on it.\n * This way we can have the dashed lines in a separate style connecting the former. */" ]
[ { "param": "v1", "type": "void" }, { "param": "v2", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_sort
void
static void outliner_sort(ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; te = lb->last; if (te == NULL) { return; } tselem = TREESTORE(te); /* sorting rules; only object lists, ID lists, or deformgroups */ if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); tTreeSort *tp = tear; int skip = 0; for (te = lb->first; te; te = te->next, tp++) { tselem = TREESTORE(te); tp->te = te; tp->name = te->name; tp->idcode = te->idcode; if (tselem->type && tselem->type != TSE_DEFGROUP) { tp->idcode = 0; // don't sort this } if (tselem->type == TSE_ID_BASE) { tp->idcode = 1; // do sort this } tp->id = tselem->id; } /* just sort alphabetically */ if (tear->idcode == 1) { qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha); } else { /* keep beginning of list */ for (tp = tear, skip = 0; skip < totelem; skip++, tp++) { if (tp->idcode) { break; } } if (skip < totelem) { qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); } } BLI_listbase_clear(lb); tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); tp++; } MEM_freeN(tear); } } for (te = lb->first; te; te = te->next) { outliner_sort(&te->subtree); } }
/* sort happens on each subtree individual */
sort happens on each subtree individual
[ "sort", "happens", "on", "each", "subtree", "individual" ]
static void outliner_sort(ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; te = lb->last; if (te == NULL) { return; } tselem = TREESTORE(te); if (ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) { int totelem = BLI_listbase_count(lb); if (totelem > 1) { tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); tTreeSort *tp = tear; int skip = 0; for (te = lb->first; te; te = te->next, tp++) { tselem = TREESTORE(te); tp->te = te; tp->name = te->name; tp->idcode = te->idcode; if (tselem->type && tselem->type != TSE_DEFGROUP) { tp->idcode = 0; } if (tselem->type == TSE_ID_BASE) { tp->idcode = 1; } tp->id = tselem->id; } if (tear->idcode == 1) { qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha); } else { for (tp = tear, skip = 0; skip < totelem; skip++, tp++) { if (tp->idcode) { break; } } if (skip < totelem) { qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); } } BLI_listbase_clear(lb); tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); tp++; } MEM_freeN(tear); } } for (te = lb->first; te; te = te->next) { outliner_sort(&te->subtree); } }
[ "static", "void", "outliner_sort", "(", "ListBase", "*", "lb", ")", "{", "TreeElement", "*", "te", ";", "TreeStoreElem", "*", "tselem", ";", "te", "=", "lb", "->", "last", ";", "if", "(", "te", "==", "NULL", ")", "{", "return", ";", "}", "tselem", "=", "TREESTORE", "(", "te", ")", ";", "if", "(", "ELEM", "(", "tselem", "->", "type", ",", "TSE_DEFGROUP", ",", "TSE_ID_BASE", ")", "||", "(", "tselem", "->", "type", "==", "0", "&&", "te", "->", "idcode", "==", "ID_OB", ")", ")", "{", "int", "totelem", "=", "BLI_listbase_count", "(", "lb", ")", ";", "if", "(", "totelem", ">", "1", ")", "{", "tTreeSort", "*", "tear", "=", "MEM_mallocN", "(", "totelem", "*", "sizeof", "(", "tTreeSort", ")", ",", "\"", "\"", ")", ";", "tTreeSort", "*", "tp", "=", "tear", ";", "int", "skip", "=", "0", ";", "for", "(", "te", "=", "lb", "->", "first", ";", "te", ";", "te", "=", "te", "->", "next", ",", "tp", "++", ")", "{", "tselem", "=", "TREESTORE", "(", "te", ")", ";", "tp", "->", "te", "=", "te", ";", "tp", "->", "name", "=", "te", "->", "name", ";", "tp", "->", "idcode", "=", "te", "->", "idcode", ";", "if", "(", "tselem", "->", "type", "&&", "tselem", "->", "type", "!=", "TSE_DEFGROUP", ")", "{", "tp", "->", "idcode", "=", "0", ";", "}", "if", "(", "tselem", "->", "type", "==", "TSE_ID_BASE", ")", "{", "tp", "->", "idcode", "=", "1", ";", "}", "tp", "->", "id", "=", "tselem", "->", "id", ";", "}", "if", "(", "tear", "->", "idcode", "==", "1", ")", "{", "qsort", "(", "tear", ",", "totelem", ",", "sizeof", "(", "tTreeSort", ")", ",", "treesort_alpha", ")", ";", "}", "else", "{", "for", "(", "tp", "=", "tear", ",", "skip", "=", "0", ";", "skip", "<", "totelem", ";", "skip", "++", ",", "tp", "++", ")", "{", "if", "(", "tp", "->", "idcode", ")", "{", "break", ";", "}", "}", "if", "(", "skip", "<", "totelem", ")", "{", "qsort", "(", "tear", "+", "skip", ",", "totelem", "-", "skip", ",", "sizeof", "(", "tTreeSort", ")", ",", "treesort_alpha_ob", ")", ";", "}", "}", "BLI_listbase_clear", "(", "lb", ")", ";", "tp", "=", "tear", ";", "while", "(", "totelem", "--", ")", "{", "BLI_addtail", "(", "lb", ",", "tp", "->", "te", ")", ";", "tp", "++", ";", "}", "MEM_freeN", "(", "tear", ")", ";", "}", "}", "for", "(", "te", "=", "lb", "->", "first", ";", "te", ";", "te", "=", "te", "->", "next", ")", "{", "outliner_sort", "(", "&", "te", "->", "subtree", ")", ";", "}", "}" ]
sort happens on each subtree individual
[ "sort", "happens", "on", "each", "subtree", "individual" ]
[ "/* sorting rules; only object lists, ID lists, or deformgroups */", "// don't sort this", "// do sort this", "/* just sort alphabetically */", "/* keep beginning of list */" ]
[ { "param": "lb", "type": "ListBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lb", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_restore_scrolling_position
void
static void outliner_restore_scrolling_position(SpaceOutliner *soops, ARegion *ar, OutlinerTreeElementFocus *focus) { View2D *v2d = &ar->v2d; if (focus->tselem != NULL) { outliner_set_coordinates(ar, soops); TreeElement *te_new = outliner_find_tree_element(&soops->tree, focus->tselem); if (te_new != NULL) { int ys_new = te_new->ys; int ys_old = focus->ys; float y_move = MIN2(ys_new - ys_old, -v2d->cur.ymax); BLI_rctf_translate(&v2d->cur, 0, y_move); } else { return; } } }
/** * Bring the outliner scrolling back to where it was in relation to the original focus element * Caller is expected to handle redrawing of ARegion. */
Bring the outliner scrolling back to where it was in relation to the original focus element Caller is expected to handle redrawing of ARegion.
[ "Bring", "the", "outliner", "scrolling", "back", "to", "where", "it", "was", "in", "relation", "to", "the", "original", "focus", "element", "Caller", "is", "expected", "to", "handle", "redrawing", "of", "ARegion", "." ]
static void outliner_restore_scrolling_position(SpaceOutliner *soops, ARegion *ar, OutlinerTreeElementFocus *focus) { View2D *v2d = &ar->v2d; if (focus->tselem != NULL) { outliner_set_coordinates(ar, soops); TreeElement *te_new = outliner_find_tree_element(&soops->tree, focus->tselem); if (te_new != NULL) { int ys_new = te_new->ys; int ys_old = focus->ys; float y_move = MIN2(ys_new - ys_old, -v2d->cur.ymax); BLI_rctf_translate(&v2d->cur, 0, y_move); } else { return; } } }
[ "static", "void", "outliner_restore_scrolling_position", "(", "SpaceOutliner", "*", "soops", ",", "ARegion", "*", "ar", ",", "OutlinerTreeElementFocus", "*", "focus", ")", "{", "View2D", "*", "v2d", "=", "&", "ar", "->", "v2d", ";", "if", "(", "focus", "->", "tselem", "!=", "NULL", ")", "{", "outliner_set_coordinates", "(", "ar", ",", "soops", ")", ";", "TreeElement", "*", "te_new", "=", "outliner_find_tree_element", "(", "&", "soops", "->", "tree", ",", "focus", "->", "tselem", ")", ";", "if", "(", "te_new", "!=", "NULL", ")", "{", "int", "ys_new", "=", "te_new", "->", "ys", ";", "int", "ys_old", "=", "focus", "->", "ys", ";", "float", "y_move", "=", "MIN2", "(", "ys_new", "-", "ys_old", ",", "-", "v2d", "->", "cur", ".", "ymax", ")", ";", "BLI_rctf_translate", "(", "&", "v2d", "->", "cur", ",", "0", ",", "y_move", ")", ";", "}", "else", "{", "return", ";", "}", "}", "}" ]
Bring the outliner scrolling back to where it was in relation to the original focus element Caller is expected to handle redrawing of ARegion.
[ "Bring", "the", "outliner", "scrolling", "back", "to", "where", "it", "was", "in", "relation", "to", "the", "original", "focus", "element", "Caller", "is", "expected", "to", "handle", "redrawing", "of", "ARegion", "." ]
[]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "ar", "type": "ARegion" }, { "param": "focus", "type": "OutlinerTreeElementFocus" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ar", "type": "ARegion", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "focus", "type": "OutlinerTreeElementFocus", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_find_first_desired_element_at_y_recursive
TreeElement
static TreeElement *outliner_find_first_desired_element_at_y_recursive( const SpaceOutliner *soops, TreeElement *te, const float limit, bool (*callback_test)(TreeElement *)) { if (callback_test(te)) { return te; } if (TSELEM_OPEN(te->store_elem, soops)) { TreeElement *te_iter, *te_sub; for (te_iter = te->subtree.first; te_iter; te_iter = te_iter->next) { te_sub = outliner_find_first_desired_element_at_y_recursive( soops, te_iter, limit, callback_test); if (te_sub != NULL) { return te_sub; } } } return NULL; }
/** * See if TreeElement or any of its children pass the callback_test. */
See if TreeElement or any of its children pass the callback_test.
[ "See", "if", "TreeElement", "or", "any", "of", "its", "children", "pass", "the", "callback_test", "." ]
static TreeElement *outliner_find_first_desired_element_at_y_recursive( const SpaceOutliner *soops, TreeElement *te, const float limit, bool (*callback_test)(TreeElement *)) { if (callback_test(te)) { return te; } if (TSELEM_OPEN(te->store_elem, soops)) { TreeElement *te_iter, *te_sub; for (te_iter = te->subtree.first; te_iter; te_iter = te_iter->next) { te_sub = outliner_find_first_desired_element_at_y_recursive( soops, te_iter, limit, callback_test); if (te_sub != NULL) { return te_sub; } } } return NULL; }
[ "static", "TreeElement", "*", "outliner_find_first_desired_element_at_y_recursive", "(", "const", "SpaceOutliner", "*", "soops", ",", "TreeElement", "*", "te", ",", "const", "float", "limit", ",", "bool", "(", "*", "callback_test", ")", "(", "TreeElement", "*", ")", ")", "{", "if", "(", "callback_test", "(", "te", ")", ")", "{", "return", "te", ";", "}", "if", "(", "TSELEM_OPEN", "(", "te", "->", "store_elem", ",", "soops", ")", ")", "{", "TreeElement", "*", "te_iter", ",", "*", "te_sub", ";", "for", "(", "te_iter", "=", "te", "->", "subtree", ".", "first", ";", "te_iter", ";", "te_iter", "=", "te_iter", "->", "next", ")", "{", "te_sub", "=", "outliner_find_first_desired_element_at_y_recursive", "(", "soops", ",", "te_iter", ",", "limit", ",", "callback_test", ")", ";", "if", "(", "te_sub", "!=", "NULL", ")", "{", "return", "te_sub", ";", "}", "}", "}", "return", "NULL", ";", "}" ]
See if TreeElement or any of its children pass the callback_test.
[ "See", "if", "TreeElement", "or", "any", "of", "its", "children", "pass", "the", "callback_test", "." ]
[]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "te", "type": "TreeElement" }, { "param": "limit", "type": "float" }, { "param": "callback_test", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "te", "type": "TreeElement", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "limit", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback_test", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_find_first_desired_element_at_y
TreeElement
static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner *soops, const float view_co, const float view_co_limit) { TreeElement *te, *te_sub; te = outliner_find_item_at_y(soops, &soops->tree, view_co); bool (*callback_test)(TreeElement *); if ((soops->outlinevis == SO_VIEW_LAYER) && (soops->filter & SO_FILTER_NO_COLLECTION)) { callback_test = test_object_callback; } else { callback_test = test_collection_callback; } while (te != NULL) { te_sub = outliner_find_first_desired_element_at_y_recursive( soops, te, view_co_limit, callback_test); if (te_sub != NULL) { /* Skip the element if it was not visible to start with. */ if (te->ys + UI_UNIT_Y > view_co_limit) { return te_sub; } else { return NULL; } } if (te->next) { te = te->next; continue; } if (te->parent == NULL) { break; } while (te->parent) { if (te->parent->next) { te = te->parent->next; break; } te = te->parent; } } return NULL; }
/** * Find the first element that passes a test starting from a reference vertical coordinate * * If the element that is in the position is not what we are looking for, keep looking for its * children, siblings, and eventually, aunts, cousins, distant families, ... etc. * * Basically we keep going up and down the outliner tree from that point forward, until we find * what we are looking for. If we are past the visible range and we can't find a valid element * we return NULL. */
Find the first element that passes a test starting from a reference vertical coordinate If the element that is in the position is not what we are looking for, keep looking for its children, siblings, and eventually, aunts, cousins, distant families, ... etc. Basically we keep going up and down the outliner tree from that point forward, until we find what we are looking for. If we are past the visible range and we can't find a valid element we return NULL.
[ "Find", "the", "first", "element", "that", "passes", "a", "test", "starting", "from", "a", "reference", "vertical", "coordinate", "If", "the", "element", "that", "is", "in", "the", "position", "is", "not", "what", "we", "are", "looking", "for", "keep", "looking", "for", "its", "children", "siblings", "and", "eventually", "aunts", "cousins", "distant", "families", "...", "etc", ".", "Basically", "we", "keep", "going", "up", "and", "down", "the", "outliner", "tree", "from", "that", "point", "forward", "until", "we", "find", "what", "we", "are", "looking", "for", ".", "If", "we", "are", "past", "the", "visible", "range", "and", "we", "can", "'", "t", "find", "a", "valid", "element", "we", "return", "NULL", "." ]
static TreeElement *outliner_find_first_desired_element_at_y(const SpaceOutliner *soops, const float view_co, const float view_co_limit) { TreeElement *te, *te_sub; te = outliner_find_item_at_y(soops, &soops->tree, view_co); bool (*callback_test)(TreeElement *); if ((soops->outlinevis == SO_VIEW_LAYER) && (soops->filter & SO_FILTER_NO_COLLECTION)) { callback_test = test_object_callback; } else { callback_test = test_collection_callback; } while (te != NULL) { te_sub = outliner_find_first_desired_element_at_y_recursive( soops, te, view_co_limit, callback_test); if (te_sub != NULL) { if (te->ys + UI_UNIT_Y > view_co_limit) { return te_sub; } else { return NULL; } } if (te->next) { te = te->next; continue; } if (te->parent == NULL) { break; } while (te->parent) { if (te->parent->next) { te = te->parent->next; break; } te = te->parent; } } return NULL; }
[ "static", "TreeElement", "*", "outliner_find_first_desired_element_at_y", "(", "const", "SpaceOutliner", "*", "soops", ",", "const", "float", "view_co", ",", "const", "float", "view_co_limit", ")", "{", "TreeElement", "*", "te", ",", "*", "te_sub", ";", "te", "=", "outliner_find_item_at_y", "(", "soops", ",", "&", "soops", "->", "tree", ",", "view_co", ")", ";", "bool", "(", "*", "callback_test", ")", "(", "TreeElement", "*", ")", ";", "if", "(", "(", "soops", "->", "outlinevis", "==", "SO_VIEW_LAYER", ")", "&&", "(", "soops", "->", "filter", "&", "SO_FILTER_NO_COLLECTION", ")", ")", "{", "callback_test", "=", "test_object_callback", ";", "}", "else", "{", "callback_test", "=", "test_collection_callback", ";", "}", "while", "(", "te", "!=", "NULL", ")", "{", "te_sub", "=", "outliner_find_first_desired_element_at_y_recursive", "(", "soops", ",", "te", ",", "view_co_limit", ",", "callback_test", ")", ";", "if", "(", "te_sub", "!=", "NULL", ")", "{", "if", "(", "te", "->", "ys", "+", "UI_UNIT_Y", ">", "view_co_limit", ")", "{", "return", "te_sub", ";", "}", "else", "{", "return", "NULL", ";", "}", "}", "if", "(", "te", "->", "next", ")", "{", "te", "=", "te", "->", "next", ";", "continue", ";", "}", "if", "(", "te", "->", "parent", "==", "NULL", ")", "{", "break", ";", "}", "while", "(", "te", "->", "parent", ")", "{", "if", "(", "te", "->", "parent", "->", "next", ")", "{", "te", "=", "te", "->", "parent", "->", "next", ";", "break", ";", "}", "te", "=", "te", "->", "parent", ";", "}", "}", "return", "NULL", ";", "}" ]
Find the first element that passes a test starting from a reference vertical coordinate If the element that is in the position is not what we are looking for, keep looking for its children, siblings, and eventually, aunts, cousins, distant families, ... etc.
[ "Find", "the", "first", "element", "that", "passes", "a", "test", "starting", "from", "a", "reference", "vertical", "coordinate", "If", "the", "element", "that", "is", "in", "the", "position", "is", "not", "what", "we", "are", "looking", "for", "keep", "looking", "for", "its", "children", "siblings", "and", "eventually", "aunts", "cousins", "distant", "families", "...", "etc", "." ]
[ "/* Skip the element if it was not visible to start with. */" ]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "view_co", "type": "float" }, { "param": "view_co_limit", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "view_co", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "view_co_limit", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7f7cfff12ef53a5ea91571360dd8abde81798734
DemonRem/blender
source/blender/editors/space_outliner/outliner_tree.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
outliner_store_scrolling_position
void
static void outliner_store_scrolling_position(SpaceOutliner *soops, ARegion *ar, OutlinerTreeElementFocus *focus) { TreeElement *te; float limit = ar->v2d.cur.ymin; outliner_set_coordinates(ar, soops); te = outliner_find_first_desired_element_at_y(soops, ar->v2d.cur.ymax, limit); if (te != NULL) { focus->tselem = TREESTORE(te); focus->ys = te->ys; } else { focus->tselem = NULL; } }
/** * Store information of current outliner scrolling status to be restored later. * * Finds the top-most collection visible in the outliner and populates the * #OutlinerTreeElementFocus struct to retrieve this element later to make sure it is in the same * original position as before filtering. */
Store information of current outliner scrolling status to be restored later. Finds the top-most collection visible in the outliner and populates the #OutlinerTreeElementFocus struct to retrieve this element later to make sure it is in the same original position as before filtering.
[ "Store", "information", "of", "current", "outliner", "scrolling", "status", "to", "be", "restored", "later", ".", "Finds", "the", "top", "-", "most", "collection", "visible", "in", "the", "outliner", "and", "populates", "the", "#OutlinerTreeElementFocus", "struct", "to", "retrieve", "this", "element", "later", "to", "make", "sure", "it", "is", "in", "the", "same", "original", "position", "as", "before", "filtering", "." ]
static void outliner_store_scrolling_position(SpaceOutliner *soops, ARegion *ar, OutlinerTreeElementFocus *focus) { TreeElement *te; float limit = ar->v2d.cur.ymin; outliner_set_coordinates(ar, soops); te = outliner_find_first_desired_element_at_y(soops, ar->v2d.cur.ymax, limit); if (te != NULL) { focus->tselem = TREESTORE(te); focus->ys = te->ys; } else { focus->tselem = NULL; } }
[ "static", "void", "outliner_store_scrolling_position", "(", "SpaceOutliner", "*", "soops", ",", "ARegion", "*", "ar", ",", "OutlinerTreeElementFocus", "*", "focus", ")", "{", "TreeElement", "*", "te", ";", "float", "limit", "=", "ar", "->", "v2d", ".", "cur", ".", "ymin", ";", "outliner_set_coordinates", "(", "ar", ",", "soops", ")", ";", "te", "=", "outliner_find_first_desired_element_at_y", "(", "soops", ",", "ar", "->", "v2d", ".", "cur", ".", "ymax", ",", "limit", ")", ";", "if", "(", "te", "!=", "NULL", ")", "{", "focus", "->", "tselem", "=", "TREESTORE", "(", "te", ")", ";", "focus", "->", "ys", "=", "te", "->", "ys", ";", "}", "else", "{", "focus", "->", "tselem", "=", "NULL", ";", "}", "}" ]
Store information of current outliner scrolling status to be restored later.
[ "Store", "information", "of", "current", "outliner", "scrolling", "status", "to", "be", "restored", "later", "." ]
[]
[ { "param": "soops", "type": "SpaceOutliner" }, { "param": "ar", "type": "ARegion" }, { "param": "focus", "type": "OutlinerTreeElementFocus" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "soops", "type": "SpaceOutliner", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ar", "type": "ARegion", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "focus", "type": "OutlinerTreeElementFocus", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
UI_draw_icon_tri
void
void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) { float f3 = 0.05 * U.widget_unit; float f5 = 0.15 * U.widget_unit; float f7 = 0.25 * U.widget_unit; if (dir == 'h') { UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color); } else if (dir == 't') { UI_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, color); } else { /* 'v' = vertical, down */ UI_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, color); } }
/* triangle 'icon' for panel header */
triangle 'icon' for panel header
[ "triangle", "'", "icon", "'", "for", "panel", "header" ]
void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) { float f3 = 0.05 * U.widget_unit; float f5 = 0.15 * U.widget_unit; float f7 = 0.25 * U.widget_unit; if (dir == 'h') { UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color); } else if (dir == 't') { UI_draw_anti_tria(x - f5, y - f7, x + f5, y - f7, x, y + f3, color); } else { UI_draw_anti_tria(x - f5, y + f3, x + f5, y + f3, x, y - f7, color); } }
[ "void", "UI_draw_icon_tri", "(", "float", "x", ",", "float", "y", ",", "char", "dir", ",", "const", "float", "color", "[", "4", "]", ")", "{", "float", "f3", "=", "0.05", "*", "U", ".", "widget_unit", ";", "float", "f5", "=", "0.15", "*", "U", ".", "widget_unit", ";", "float", "f7", "=", "0.25", "*", "U", ".", "widget_unit", ";", "if", "(", "dir", "==", "'", "'", ")", "{", "UI_draw_anti_tria", "(", "x", "-", "f3", ",", "y", "-", "f5", ",", "x", "-", "f3", ",", "y", "+", "f5", ",", "x", "+", "f7", ",", "y", ",", "color", ")", ";", "}", "else", "if", "(", "dir", "==", "'", "'", ")", "{", "UI_draw_anti_tria", "(", "x", "-", "f5", ",", "y", "-", "f7", ",", "x", "+", "f5", ",", "y", "-", "f7", ",", "x", ",", "y", "+", "f3", ",", "color", ")", ";", "}", "else", "{", "UI_draw_anti_tria", "(", "x", "-", "f5", ",", "y", "+", "f3", ",", "x", "+", "f5", ",", "y", "+", "f3", ",", "x", ",", "y", "-", "f7", ",", "color", ")", ";", "}", "}" ]
triangle 'icon' for panel header
[ "triangle", "'", "icon", "'", "for", "panel", "header" ]
[ "/* 'v' = vertical, down */" ]
[ { "param": "x", "type": "float" }, { "param": "y", "type": "float" }, { "param": "dir", "type": "char" }, { "param": "color", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dir", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "color", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
ui_draw_x_icon
void
static void ui_draw_x_icon(uint pos, float x, float y) { ui_draw_anti_x(pos, x, y, x + 9.375f, y + 9.375f); }
/* x 'icon' for panel header */
x 'icon' for panel header
[ "x", "'", "icon", "'", "for", "panel", "header" ]
static void ui_draw_x_icon(uint pos, float x, float y) { ui_draw_anti_x(pos, x, y, x + 9.375f, y + 9.375f); }
[ "static", "void", "ui_draw_x_icon", "(", "uint", "pos", ",", "float", "x", ",", "float", "y", ")", "{", "ui_draw_anti_x", "(", "pos", ",", "x", ",", "y", ",", "x", "+", "9.375f", ",", "y", "+", "9.375f", ")", ";", "}" ]
x 'icon' for panel header
[ "x", "'", "icon", "'", "for", "panel", "header" ]
[]
[ { "param": "pos", "type": "uint" }, { "param": "x", "type": "float" }, { "param": "y", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pos", "type": "uint", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "y", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
find_leftmost_panel
int
static int find_leftmost_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; if (ps1->pa->ofsx > ps2->pa->ofsx) { return 1; } else if (ps1->pa->ofsx < ps2->pa->ofsx) { return -1; } else if (ps1->pa->sortorder > ps2->pa->sortorder) { return 1; } else if (ps1->pa->sortorder < ps2->pa->sortorder) { return -1; } return 0; }
/** * \note about sorting; * the sortorder has a lower value for new panels being added. * however, that only works to insert a single panel, when more new panels get * added the coordinates of existing panels and the previously stored to-be-inserted * panels do not match for sorting */
\note about sorting; the sortorder has a lower value for new panels being added. however, that only works to insert a single panel, when more new panels get added the coordinates of existing panels and the previously stored to-be-inserted panels do not match for sorting
[ "\\", "note", "about", "sorting", ";", "the", "sortorder", "has", "a", "lower", "value", "for", "new", "panels", "being", "added", ".", "however", "that", "only", "works", "to", "insert", "a", "single", "panel", "when", "more", "new", "panels", "get", "added", "the", "coordinates", "of", "existing", "panels", "and", "the", "previously", "stored", "to", "-", "be", "-", "inserted", "panels", "do", "not", "match", "for", "sorting" ]
static int find_leftmost_panel(const void *a1, const void *a2) { const PanelSort *ps1 = a1, *ps2 = a2; if (ps1->pa->ofsx > ps2->pa->ofsx) { return 1; } else if (ps1->pa->ofsx < ps2->pa->ofsx) { return -1; } else if (ps1->pa->sortorder > ps2->pa->sortorder) { return 1; } else if (ps1->pa->sortorder < ps2->pa->sortorder) { return -1; } return 0; }
[ "static", "int", "find_leftmost_panel", "(", "const", "void", "*", "a1", ",", "const", "void", "*", "a2", ")", "{", "const", "PanelSort", "*", "ps1", "=", "a1", ",", "*", "ps2", "=", "a2", ";", "if", "(", "ps1", "->", "pa", "->", "ofsx", ">", "ps2", "->", "pa", "->", "ofsx", ")", "{", "return", "1", ";", "}", "else", "if", "(", "ps1", "->", "pa", "->", "ofsx", "<", "ps2", "->", "pa", "->", "ofsx", ")", "{", "return", "-1", ";", "}", "else", "if", "(", "ps1", "->", "pa", "->", "sortorder", ">", "ps2", "->", "pa", "->", "sortorder", ")", "{", "return", "1", ";", "}", "else", "if", "(", "ps1", "->", "pa", "->", "sortorder", "<", "ps2", "->", "pa", "->", "sortorder", ")", "{", "return", "-1", ";", "}", "return", "0", ";", "}" ]
\note about sorting; the sortorder has a lower value for new panels being added.
[ "\\", "note", "about", "sorting", ";", "the", "sortorder", "has", "a", "lower", "value", "for", "new", "panels", "being", "added", "." ]
[]
[ { "param": "a1", "type": "void" }, { "param": "a2", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a1", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "a2", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
uiAlignPanelStep
bool
static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bool drag) { Panel *pa; PanelSort *ps, *panelsort, *psnext; int a, tot = 0; bool done; int align = panel_aligned(sa, ar); bool has_category_tabs = UI_panel_category_is_visible(ar); /* count active, not tabbed panels */ for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { tot++; } } if (tot == 0) { return 0; } /* extra; change close direction? */ for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { pa->flag ^= PNL_CLOSED; } else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { pa->flag ^= PNL_CLOSED; } } } /* sort panels */ panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort"); ps = panelsort; for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { ps->pa = MEM_dupallocN(pa); ps->orig = pa; ps++; } } if (drag) { /* while we are dragging, we sort on location and update sortorder */ if (align == BUT_VERTICAL) { qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); } else { qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); } for (ps = panelsort, a = 0; a < tot; a++, ps++) { ps->orig->sortorder = a; } } else { /* otherwise use sortorder */ qsort(panelsort, tot, sizeof(PanelSort), compare_panel); } /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps = panelsort; ps->pa->ofsx = 0; ps->pa->ofsy = -get_panel_size_y(ps->pa); if (has_category_tabs) { if (align == BUT_VERTICAL && (ar->alignment != RGN_ALIGN_RIGHT)) { ps->pa->ofsx += UI_PANEL_CATEGORY_MARGIN_WIDTH; } } for (a = 0; a < tot - 1; a++, ps++) { psnext = ps + 1; if (align == BUT_VERTICAL) { psnext->pa->ofsx = ps->pa->ofsx; psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); } else { psnext->pa->ofsx = get_panel_real_ofsx(ps->pa); psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); } } /* we interpolate */ done = false; ps = panelsort; for (a = 0; a < tot; a++, ps++) { if ((ps->pa->flag & PNL_SELECT) == 0) { if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx); ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy); done = true; } } } /* set locations for tabbed and sub panels */ for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { if (pa->children.first) { align_sub_panels(pa); } } } /* free panelsort array */ for (ps = panelsort, a = 0; a < tot; a++, ps++) { MEM_freeN(ps->pa); } MEM_freeN(panelsort); return done; }
/* this doesn't draw */ /* returns 1 when it did something */
this doesn't draw returns 1 when it did something
[ "this", "doesn", "'", "t", "draw", "returns", "1", "when", "it", "did", "something" ]
static bool uiAlignPanelStep(ScrArea *sa, ARegion *ar, const float fac, const bool drag) { Panel *pa; PanelSort *ps, *panelsort, *psnext; int a, tot = 0; bool done; int align = panel_aligned(sa, ar); bool has_category_tabs = UI_panel_category_is_visible(ar); for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { tot++; } } if (tot == 0) { return 0; } for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL)) { pa->flag ^= PNL_CLOSED; } else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL)) { pa->flag ^= PNL_CLOSED; } } } panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort"); ps = panelsort; for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { ps->pa = MEM_dupallocN(pa); ps->orig = pa; ps++; } } if (drag) { if (align == BUT_VERTICAL) { qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); } else { qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); } for (ps = panelsort, a = 0; a < tot; a++, ps++) { ps->orig->sortorder = a; } } else { qsort(panelsort, tot, sizeof(PanelSort), compare_panel); } ps = panelsort; ps->pa->ofsx = 0; ps->pa->ofsy = -get_panel_size_y(ps->pa); if (has_category_tabs) { if (align == BUT_VERTICAL && (ar->alignment != RGN_ALIGN_RIGHT)) { ps->pa->ofsx += UI_PANEL_CATEGORY_MARGIN_WIDTH; } } for (a = 0; a < tot - 1; a++, ps++) { psnext = ps + 1; if (align == BUT_VERTICAL) { psnext->pa->ofsx = ps->pa->ofsx; psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); } else { psnext->pa->ofsx = get_panel_real_ofsx(ps->pa); psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); } } done = false; ps = panelsort; for (a = 0; a < tot; a++, ps++) { if ((ps->pa->flag & PNL_SELECT) == 0) { if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { ps->orig->ofsx = round_fl_to_int(fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx); ps->orig->ofsy = round_fl_to_int(fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy); done = true; } } } for (pa = ar->panels.first; pa; pa = pa->next) { if (pa->runtime_flag & PNL_ACTIVE) { if (pa->children.first) { align_sub_panels(pa); } } } for (ps = panelsort, a = 0; a < tot; a++, ps++) { MEM_freeN(ps->pa); } MEM_freeN(panelsort); return done; }
[ "static", "bool", "uiAlignPanelStep", "(", "ScrArea", "*", "sa", ",", "ARegion", "*", "ar", ",", "const", "float", "fac", ",", "const", "bool", "drag", ")", "{", "Panel", "*", "pa", ";", "PanelSort", "*", "ps", ",", "*", "panelsort", ",", "*", "psnext", ";", "int", "a", ",", "tot", "=", "0", ";", "bool", "done", ";", "int", "align", "=", "panel_aligned", "(", "sa", ",", "ar", ")", ";", "bool", "has_category_tabs", "=", "UI_panel_category_is_visible", "(", "ar", ")", ";", "for", "(", "pa", "=", "ar", "->", "panels", ".", "first", ";", "pa", ";", "pa", "=", "pa", "->", "next", ")", "{", "if", "(", "pa", "->", "runtime_flag", "&", "PNL_ACTIVE", ")", "{", "tot", "++", ";", "}", "}", "if", "(", "tot", "==", "0", ")", "{", "return", "0", ";", "}", "for", "(", "pa", "=", "ar", "->", "panels", ".", "first", ";", "pa", ";", "pa", "=", "pa", "->", "next", ")", "{", "if", "(", "pa", "->", "runtime_flag", "&", "PNL_ACTIVE", ")", "{", "if", "(", "(", "pa", "->", "flag", "&", "PNL_CLOSEDX", ")", "&&", "(", "align", "==", "BUT_VERTICAL", ")", ")", "{", "pa", "->", "flag", "^=", "PNL_CLOSED", ";", "}", "else", "if", "(", "(", "pa", "->", "flag", "&", "PNL_CLOSEDY", ")", "&&", "(", "align", "==", "BUT_HORIZONTAL", ")", ")", "{", "pa", "->", "flag", "^=", "PNL_CLOSED", ";", "}", "}", "}", "panelsort", "=", "MEM_callocN", "(", "tot", "*", "sizeof", "(", "PanelSort", ")", ",", "\"", "\"", ")", ";", "ps", "=", "panelsort", ";", "for", "(", "pa", "=", "ar", "->", "panels", ".", "first", ";", "pa", ";", "pa", "=", "pa", "->", "next", ")", "{", "if", "(", "pa", "->", "runtime_flag", "&", "PNL_ACTIVE", ")", "{", "ps", "->", "pa", "=", "MEM_dupallocN", "(", "pa", ")", ";", "ps", "->", "orig", "=", "pa", ";", "ps", "++", ";", "}", "}", "if", "(", "drag", ")", "{", "if", "(", "align", "==", "BUT_VERTICAL", ")", "{", "qsort", "(", "panelsort", ",", "tot", ",", "sizeof", "(", "PanelSort", ")", ",", "find_highest_panel", ")", ";", "}", "else", "{", "qsort", "(", "panelsort", ",", "tot", ",", "sizeof", "(", "PanelSort", ")", ",", "find_leftmost_panel", ")", ";", "}", "for", "(", "ps", "=", "panelsort", ",", "a", "=", "0", ";", "a", "<", "tot", ";", "a", "++", ",", "ps", "++", ")", "{", "ps", "->", "orig", "->", "sortorder", "=", "a", ";", "}", "}", "else", "{", "qsort", "(", "panelsort", ",", "tot", ",", "sizeof", "(", "PanelSort", ")", ",", "compare_panel", ")", ";", "}", "ps", "=", "panelsort", ";", "ps", "->", "pa", "->", "ofsx", "=", "0", ";", "ps", "->", "pa", "->", "ofsy", "=", "-", "get_panel_size_y", "(", "ps", "->", "pa", ")", ";", "if", "(", "has_category_tabs", ")", "{", "if", "(", "align", "==", "BUT_VERTICAL", "&&", "(", "ar", "->", "alignment", "!=", "RGN_ALIGN_RIGHT", ")", ")", "{", "ps", "->", "pa", "->", "ofsx", "+=", "UI_PANEL_CATEGORY_MARGIN_WIDTH", ";", "}", "}", "for", "(", "a", "=", "0", ";", "a", "<", "tot", "-", "1", ";", "a", "++", ",", "ps", "++", ")", "{", "psnext", "=", "ps", "+", "1", ";", "if", "(", "align", "==", "BUT_VERTICAL", ")", "{", "psnext", "->", "pa", "->", "ofsx", "=", "ps", "->", "pa", "->", "ofsx", ";", "psnext", "->", "pa", "->", "ofsy", "=", "get_panel_real_ofsy", "(", "ps", "->", "pa", ")", "-", "get_panel_size_y", "(", "psnext", "->", "pa", ")", ";", "}", "else", "{", "psnext", "->", "pa", "->", "ofsx", "=", "get_panel_real_ofsx", "(", "ps", "->", "pa", ")", ";", "psnext", "->", "pa", "->", "ofsy", "=", "ps", "->", "pa", "->", "ofsy", "+", "get_panel_size_y", "(", "ps", "->", "pa", ")", "-", "get_panel_size_y", "(", "psnext", "->", "pa", ")", ";", "}", "}", "done", "=", "false", ";", "ps", "=", "panelsort", ";", "for", "(", "a", "=", "0", ";", "a", "<", "tot", ";", "a", "++", ",", "ps", "++", ")", "{", "if", "(", "(", "ps", "->", "pa", "->", "flag", "&", "PNL_SELECT", ")", "==", "0", ")", "{", "if", "(", "(", "ps", "->", "orig", "->", "ofsx", "!=", "ps", "->", "pa", "->", "ofsx", ")", "||", "(", "ps", "->", "orig", "->", "ofsy", "!=", "ps", "->", "pa", "->", "ofsy", ")", ")", "{", "ps", "->", "orig", "->", "ofsx", "=", "round_fl_to_int", "(", "fac", "*", "(", "float", ")", "ps", "->", "pa", "->", "ofsx", "+", "(", "1.0f", "-", "fac", ")", "*", "(", "float", ")", "ps", "->", "orig", "->", "ofsx", ")", ";", "ps", "->", "orig", "->", "ofsy", "=", "round_fl_to_int", "(", "fac", "*", "(", "float", ")", "ps", "->", "pa", "->", "ofsy", "+", "(", "1.0f", "-", "fac", ")", "*", "(", "float", ")", "ps", "->", "orig", "->", "ofsy", ")", ";", "done", "=", "true", ";", "}", "}", "}", "for", "(", "pa", "=", "ar", "->", "panels", ".", "first", ";", "pa", ";", "pa", "=", "pa", "->", "next", ")", "{", "if", "(", "pa", "->", "runtime_flag", "&", "PNL_ACTIVE", ")", "{", "if", "(", "pa", "->", "children", ".", "first", ")", "{", "align_sub_panels", "(", "pa", ")", ";", "}", "}", "}", "for", "(", "ps", "=", "panelsort", ",", "a", "=", "0", ";", "a", "<", "tot", ";", "a", "++", ",", "ps", "++", ")", "{", "MEM_freeN", "(", "ps", "->", "pa", ")", ";", "}", "MEM_freeN", "(", "panelsort", ")", ";", "return", "done", ";", "}" ]
this doesn't draw returns 1 when it did something
[ "this", "doesn", "'", "t", "draw", "returns", "1", "when", "it", "did", "something" ]
[ "/* count active, not tabbed panels */", "/* extra; change close direction? */", "/* sort panels */", "/* while we are dragging, we sort on location and update sortorder */", "/* otherwise use sortorder */", "/* no smart other default start loc! this keeps switching f5/f6/etc compatible */", "/* we interpolate */", "/* set locations for tabbed and sub panels */", "/* free panelsort array */" ]
[ { "param": "sa", "type": "ScrArea" }, { "param": "ar", "type": "ARegion" }, { "param": "fac", "type": "float" }, { "param": "drag", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sa", "type": "ScrArea", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ar", "type": "ARegion", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fac", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "drag", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
ui_handle_panel_header
void
static void ui_handle_panel_header( const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); #ifdef USE_PIN_HIDDEN const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->type->parent == NULL) && (block->panel->flag & PNL_PIN); #else const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->type->parent == NULL); #endif const bool is_subpanel = (block->panel->type && block->panel->type->parent); const bool show_drag = !is_subpanel; int align = panel_aligned(sa, ar), button = 0; rctf rect_drag, rect_pin; float rect_leftmost; /* drag and pin rect's */ rect_drag = block->rect; rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f); rect_pin = rect_drag; if (show_pin) { BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f); } rect_leftmost = rect_pin.xmin; /* mouse coordinates in panel space! */ /* XXX weak code, currently it assumes layout style for location of widgets */ /* check open/collapsed button */ if (event == RETKEY) { button = 1; } else if (event == AKEY) { button = 1; } else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) { if (block->panel->type->parent == NULL) { block->panel->flag ^= PNL_PIN; button = 2; } } else if (block->panel->flag & PNL_CLOSEDX) { if (my >= block->rect.ymax) { button = 1; } } else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ if (mx <= block->rect.xmax - 8 - PNL_ICON) { button = 2; } // else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) { // button = 1; //} } else if (mx < rect_leftmost) { button = 1; } if (button) { if (button == 2) { /* close */ ED_region_tag_redraw(ar); } else { /* collapse */ if (ctrl) { panels_collapse_all(sa, ar, block->panel); /* reset the view - we don't want to display a view without content */ UI_view2d_offset(&ar->v2d, 0.0f, 1.0f); } if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; /* snap back up so full panel aligns with screen edge */ if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = 0; } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, false); } } else if (align == BUT_HORIZONTAL) { block->panel->flag |= PNL_CLOSEDX; if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, true); } } else { /* snap down to bottom screen edge */ block->panel->flag |= PNL_CLOSEDY; if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = -block->panel->sizey; } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, true); } } } if (align) { panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION); } else { /* FIXME: this doesn't update the panel drawing, assert to avoid debugging why this is. * We could fix this in the future if it's ever needed. */ BLI_assert(0); ED_region_tag_redraw(ar); } } else if (show_drag && BLI_rctf_isect_x(&rect_drag, mx)) { /* XXX, for now don't allow dragging in floating windows yet. */ if (ar->alignment == RGN_ALIGN_FLOAT) { return; } panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) { block->panel->flag ^= PNL_PIN; ED_region_tag_redraw(ar); } }
/* this function is supposed to call general window drawing too */ /* also it supposes a block has panel, and isn't a menu */
this function is supposed to call general window drawing too also it supposes a block has panel, and isn't a menu
[ "this", "function", "is", "supposed", "to", "call", "general", "window", "drawing", "too", "also", "it", "supposes", "a", "block", "has", "panel", "and", "isn", "'", "t", "a", "menu" ]
static void ui_handle_panel_header( const bContext *C, uiBlock *block, int mx, int my, int event, short ctrl, short shift) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); #ifdef USE_PIN_HIDDEN const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->type->parent == NULL) && (block->panel->flag & PNL_PIN); #else const bool show_pin = UI_panel_category_is_visible(ar) && (block->panel->type->parent == NULL); #endif const bool is_subpanel = (block->panel->type && block->panel->type->parent); const bool show_drag = !is_subpanel; int align = panel_aligned(sa, ar), button = 0; rctf rect_drag, rect_pin; float rect_leftmost; rect_drag = block->rect; rect_drag.xmin = block->rect.xmax - (PNL_ICON * 1.5f); rect_pin = rect_drag; if (show_pin) { BLI_rctf_translate(&rect_pin, -PNL_ICON, 0.0f); } rect_leftmost = rect_pin.xmin; if (event == RETKEY) { button = 1; } else if (event == AKEY) { button = 1; } else if (ELEM(event, 0, RETKEY, LEFTMOUSE) && shift) { if (block->panel->type->parent == NULL) { block->panel->flag ^= PNL_PIN; button = 2; } } else if (block->panel->flag & PNL_CLOSEDX) { if (my >= block->rect.ymax) { button = 1; } } else if (block->panel->control & UI_PNL_CLOSE) { if (mx <= block->rect.xmax - 8 - PNL_ICON) { button = 2; } } else if (mx < rect_leftmost) { button = 1; } if (button) { if (button == 2) { ED_region_tag_redraw(ar); } else { if (ctrl) { panels_collapse_all(sa, ar, block->panel); UI_view2d_offset(&ar->v2d, 0.0f, 1.0f); } if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = 0; } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, false); } } else if (align == BUT_HORIZONTAL) { block->panel->flag |= PNL_CLOSEDX; if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, true); } } else { block->panel->flag |= PNL_CLOSEDY; if (block->panel->snap & PNL_SNAP_BOTTOM) { block->panel->ofsy = -block->panel->sizey; } if (event == LEFTMOUSE) { ui_panel_drag_collapse_handler_add(C, true); } } } if (align) { panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION); } else { BLI_assert(0); ED_region_tag_redraw(ar); } } else if (show_drag && BLI_rctf_isect_x(&rect_drag, mx)) { if (ar->alignment == RGN_ALIGN_FLOAT) { return; } panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } else if (show_pin && BLI_rctf_isect_x(&rect_pin, mx)) { block->panel->flag ^= PNL_PIN; ED_region_tag_redraw(ar); } }
[ "static", "void", "ui_handle_panel_header", "(", "const", "bContext", "*", "C", ",", "uiBlock", "*", "block", ",", "int", "mx", ",", "int", "my", ",", "int", "event", ",", "short", "ctrl", ",", "short", "shift", ")", "{", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "ARegion", "*", "ar", "=", "CTX_wm_region", "(", "C", ")", ";", "#ifdef", "USE_PIN_HIDDEN", "const", "bool", "show_pin", "=", "UI_panel_category_is_visible", "(", "ar", ")", "&&", "(", "block", "->", "panel", "->", "type", "->", "parent", "==", "NULL", ")", "&&", "(", "block", "->", "panel", "->", "flag", "&", "PNL_PIN", ")", ";", "#else", "const", "bool", "show_pin", "=", "UI_panel_category_is_visible", "(", "ar", ")", "&&", "(", "block", "->", "panel", "->", "type", "->", "parent", "==", "NULL", ")", ";", "#endif", "const", "bool", "is_subpanel", "=", "(", "block", "->", "panel", "->", "type", "&&", "block", "->", "panel", "->", "type", "->", "parent", ")", ";", "const", "bool", "show_drag", "=", "!", "is_subpanel", ";", "int", "align", "=", "panel_aligned", "(", "sa", ",", "ar", ")", ",", "button", "=", "0", ";", "rctf", "rect_drag", ",", "rect_pin", ";", "float", "rect_leftmost", ";", "rect_drag", "=", "block", "->", "rect", ";", "rect_drag", ".", "xmin", "=", "block", "->", "rect", ".", "xmax", "-", "(", "PNL_ICON", "*", "1.5f", ")", ";", "rect_pin", "=", "rect_drag", ";", "if", "(", "show_pin", ")", "{", "BLI_rctf_translate", "(", "&", "rect_pin", ",", "-", "PNL_ICON", ",", "0.0f", ")", ";", "}", "rect_leftmost", "=", "rect_pin", ".", "xmin", ";", "if", "(", "event", "==", "RETKEY", ")", "{", "button", "=", "1", ";", "}", "else", "if", "(", "event", "==", "AKEY", ")", "{", "button", "=", "1", ";", "}", "else", "if", "(", "ELEM", "(", "event", ",", "0", ",", "RETKEY", ",", "LEFTMOUSE", ")", "&&", "shift", ")", "{", "if", "(", "block", "->", "panel", "->", "type", "->", "parent", "==", "NULL", ")", "{", "block", "->", "panel", "->", "flag", "^=", "PNL_PIN", ";", "button", "=", "2", ";", "}", "}", "else", "if", "(", "block", "->", "panel", "->", "flag", "&", "PNL_CLOSEDX", ")", "{", "if", "(", "my", ">=", "block", "->", "rect", ".", "ymax", ")", "{", "button", "=", "1", ";", "}", "}", "else", "if", "(", "block", "->", "panel", "->", "control", "&", "UI_PNL_CLOSE", ")", "{", "if", "(", "mx", "<=", "block", "->", "rect", ".", "xmax", "-", "8", "-", "PNL_ICON", ")", "{", "button", "=", "2", ";", "}", "}", "else", "if", "(", "mx", "<", "rect_leftmost", ")", "{", "button", "=", "1", ";", "}", "if", "(", "button", ")", "{", "if", "(", "button", "==", "2", ")", "{", "ED_region_tag_redraw", "(", "ar", ")", ";", "}", "else", "{", "if", "(", "ctrl", ")", "{", "panels_collapse_all", "(", "sa", ",", "ar", ",", "block", "->", "panel", ")", ";", "UI_view2d_offset", "(", "&", "ar", "->", "v2d", ",", "0.0f", ",", "1.0f", ")", ";", "}", "if", "(", "block", "->", "panel", "->", "flag", "&", "PNL_CLOSED", ")", "{", "block", "->", "panel", "->", "flag", "&=", "~", "PNL_CLOSED", ";", "if", "(", "block", "->", "panel", "->", "snap", "&", "PNL_SNAP_BOTTOM", ")", "{", "block", "->", "panel", "->", "ofsy", "=", "0", ";", "}", "if", "(", "event", "==", "LEFTMOUSE", ")", "{", "ui_panel_drag_collapse_handler_add", "(", "C", ",", "false", ")", ";", "}", "}", "else", "if", "(", "align", "==", "BUT_HORIZONTAL", ")", "{", "block", "->", "panel", "->", "flag", "|=", "PNL_CLOSEDX", ";", "if", "(", "event", "==", "LEFTMOUSE", ")", "{", "ui_panel_drag_collapse_handler_add", "(", "C", ",", "true", ")", ";", "}", "}", "else", "{", "block", "->", "panel", "->", "flag", "|=", "PNL_CLOSEDY", ";", "if", "(", "block", "->", "panel", "->", "snap", "&", "PNL_SNAP_BOTTOM", ")", "{", "block", "->", "panel", "->", "ofsy", "=", "-", "block", "->", "panel", "->", "sizey", ";", "}", "if", "(", "event", "==", "LEFTMOUSE", ")", "{", "ui_panel_drag_collapse_handler_add", "(", "C", ",", "true", ")", ";", "}", "}", "}", "if", "(", "align", ")", "{", "panel_activate_state", "(", "C", ",", "block", "->", "panel", ",", "PANEL_STATE_ANIMATION", ")", ";", "}", "else", "{", "BLI_assert", "(", "0", ")", ";", "ED_region_tag_redraw", "(", "ar", ")", ";", "}", "}", "else", "if", "(", "show_drag", "&&", "BLI_rctf_isect_x", "(", "&", "rect_drag", ",", "mx", ")", ")", "{", "if", "(", "ar", "->", "alignment", "==", "RGN_ALIGN_FLOAT", ")", "{", "return", ";", "}", "panel_activate_state", "(", "C", ",", "block", "->", "panel", ",", "PANEL_STATE_DRAG", ")", ";", "}", "else", "if", "(", "show_pin", "&&", "BLI_rctf_isect_x", "(", "&", "rect_pin", ",", "mx", ")", ")", "{", "block", "->", "panel", "->", "flag", "^=", "PNL_PIN", ";", "ED_region_tag_redraw", "(", "ar", ")", ";", "}", "}" ]
this function is supposed to call general window drawing too also it supposes a block has panel, and isn't a menu
[ "this", "function", "is", "supposed", "to", "call", "general", "window", "drawing", "too", "also", "it", "supposes", "a", "block", "has", "panel", "and", "isn", "'", "t", "a", "menu" ]
[ "/* drag and pin rect's */", "/* mouse coordinates in panel space! */", "/* XXX weak code, currently it assumes layout style for location of widgets */", "/* check open/collapsed button */", "/* whole of header can be used to collapse panel (except top-right corner) */", "// else if (mx <= block->rect.xmin + 10 + 2 * PNL_ICON + 2) {", "// button = 1;", "//}", "/* close */", "/* collapse */", "/* reset the view - we don't want to display a view without content */", "/* snap back up so full panel aligns with screen edge */", "/* snap down to bottom screen edge */", "/* FIXME: this doesn't update the panel drawing, assert to avoid debugging why this is.\n * We could fix this in the future if it's ever needed. */", "/* XXX, for now don't allow dragging in floating windows yet. */" ]
[ { "param": "C", "type": "bContext" }, { "param": "block", "type": "uiBlock" }, { "param": "mx", "type": "int" }, { "param": "my", "type": "int" }, { "param": "event", "type": "int" }, { "param": "ctrl", "type": "short" }, { "param": "shift", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block", "type": "uiBlock", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "my", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctrl", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shift", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
ui_panel_category_draw_tab
void
static void ui_panel_category_draw_tab(bool filled, float minx, float miny, float maxx, float maxy, float rad, const int roundboxtype, const bool use_highlight, const bool use_shadow, const bool use_flip_x, const uchar highlight_fade[3], const uchar col[3]) { float vec[4][2] = {{0.195, 0.02}, {0.55, 0.169}, {0.831, 0.45}, {0.98, 0.805}}; int a; /* mult */ for (a = 0; a < 4; a++) { mul_v2_fl(vec[a], rad); } uint vert_len = 0; if (use_highlight) { vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1; vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1; } if (use_highlight && !use_shadow) { vert_len++; } else { vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1; vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1; } /* Maximum size. */ float vbuf[24][2]; uchar cbuf[24][3]; int buf_index = 0; /* start with corner right-top */ if (use_highlight) { if (roundboxtype & UI_CNR_TOP_RIGHT) { imm_buf_append(vbuf, cbuf, maxx, maxy - rad, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, maxx - vec[a][1], maxy - rad + vec[a][0], col, &buf_index); } imm_buf_append(vbuf, cbuf, maxx - rad, maxy, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, maxx, maxy, col, &buf_index); } /* corner left-top */ if (roundboxtype & UI_CNR_TOP_LEFT) { imm_buf_append(vbuf, cbuf, minx + rad, maxy, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, minx + rad - vec[a][0], maxy - vec[a][1], col, &buf_index); } imm_buf_append(vbuf, cbuf, minx, maxy - rad, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, minx, maxy, col, &buf_index); } } if (use_highlight && !use_shadow) { imm_buf_append( vbuf, cbuf, minx, miny + rad, highlight_fade ? col : highlight_fade, &buf_index); } else { /* corner left-bottom */ if (roundboxtype & UI_CNR_BOTTOM_LEFT) { imm_buf_append(vbuf, cbuf, minx, miny + rad, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, minx + vec[a][1], miny + rad - vec[a][0], col, &buf_index); } imm_buf_append(vbuf, cbuf, minx + rad, miny, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, minx, miny, col, &buf_index); } /* corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { imm_buf_append(vbuf, cbuf, maxx - rad, miny, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, maxx - rad + vec[a][0], miny + vec[a][1], col, &buf_index); } imm_buf_append(vbuf, cbuf, maxx, miny + rad, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, maxx, miny, col, &buf_index); } } if (use_flip_x) { float midx = (minx + maxx) / 2.0f; for (int i = 0; i < buf_index; i++) { vbuf[i][0] = midx - (vbuf[i][0] - midx); } } GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add( format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); for (int i = 0; i < buf_index; i++) { immAttr3ubv(color, cbuf[i]); immVertex2fv(pos, vbuf[i]); } immEnd(); immUnbindProgram(); }
/* based on UI_draw_roundbox, check on making a version which allows us to skip some sides */
based on UI_draw_roundbox, check on making a version which allows us to skip some sides
[ "based", "on", "UI_draw_roundbox", "check", "on", "making", "a", "version", "which", "allows", "us", "to", "skip", "some", "sides" ]
static void ui_panel_category_draw_tab(bool filled, float minx, float miny, float maxx, float maxy, float rad, const int roundboxtype, const bool use_highlight, const bool use_shadow, const bool use_flip_x, const uchar highlight_fade[3], const uchar col[3]) { float vec[4][2] = {{0.195, 0.02}, {0.55, 0.169}, {0.831, 0.45}, {0.98, 0.805}}; int a; for (a = 0; a < 4; a++) { mul_v2_fl(vec[a], rad); } uint vert_len = 0; if (use_highlight) { vert_len += (roundboxtype & UI_CNR_TOP_RIGHT) ? 6 : 1; vert_len += (roundboxtype & UI_CNR_TOP_LEFT) ? 6 : 1; } if (use_highlight && !use_shadow) { vert_len++; } else { vert_len += (roundboxtype & UI_CNR_BOTTOM_RIGHT) ? 6 : 1; vert_len += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 6 : 1; } float vbuf[24][2]; uchar cbuf[24][3]; int buf_index = 0; if (use_highlight) { if (roundboxtype & UI_CNR_TOP_RIGHT) { imm_buf_append(vbuf, cbuf, maxx, maxy - rad, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, maxx - vec[a][1], maxy - rad + vec[a][0], col, &buf_index); } imm_buf_append(vbuf, cbuf, maxx - rad, maxy, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, maxx, maxy, col, &buf_index); } if (roundboxtype & UI_CNR_TOP_LEFT) { imm_buf_append(vbuf, cbuf, minx + rad, maxy, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, minx + rad - vec[a][0], maxy - vec[a][1], col, &buf_index); } imm_buf_append(vbuf, cbuf, minx, maxy - rad, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, minx, maxy, col, &buf_index); } } if (use_highlight && !use_shadow) { imm_buf_append( vbuf, cbuf, minx, miny + rad, highlight_fade ? col : highlight_fade, &buf_index); } else { if (roundboxtype & UI_CNR_BOTTOM_LEFT) { imm_buf_append(vbuf, cbuf, minx, miny + rad, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, minx + vec[a][1], miny + rad - vec[a][0], col, &buf_index); } imm_buf_append(vbuf, cbuf, minx + rad, miny, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, minx, miny, col, &buf_index); } if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { imm_buf_append(vbuf, cbuf, maxx - rad, miny, col, &buf_index); for (a = 0; a < 4; a++) { imm_buf_append(vbuf, cbuf, maxx - rad + vec[a][0], miny + vec[a][1], col, &buf_index); } imm_buf_append(vbuf, cbuf, maxx, miny + rad, col, &buf_index); } else { imm_buf_append(vbuf, cbuf, maxx, miny, col, &buf_index); } } if (use_flip_x) { float midx = (minx + maxx) / 2.0f; for (int i = 0; i < buf_index; i++) { vbuf[i][0] = midx - (vbuf[i][0] - midx); } } GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add( format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); for (int i = 0; i < buf_index; i++) { immAttr3ubv(color, cbuf[i]); immVertex2fv(pos, vbuf[i]); } immEnd(); immUnbindProgram(); }
[ "static", "void", "ui_panel_category_draw_tab", "(", "bool", "filled", ",", "float", "minx", ",", "float", "miny", ",", "float", "maxx", ",", "float", "maxy", ",", "float", "rad", ",", "const", "int", "roundboxtype", ",", "const", "bool", "use_highlight", ",", "const", "bool", "use_shadow", ",", "const", "bool", "use_flip_x", ",", "const", "uchar", "highlight_fade", "[", "3", "]", ",", "const", "uchar", "col", "[", "3", "]", ")", "{", "float", "vec", "[", "4", "]", "[", "2", "]", "=", "{", "{", "0.195", ",", "0.02", "}", ",", "{", "0.55", ",", "0.169", "}", ",", "{", "0.831", ",", "0.45", "}", ",", "{", "0.98", ",", "0.805", "}", "}", ";", "int", "a", ";", "for", "(", "a", "=", "0", ";", "a", "<", "4", ";", "a", "++", ")", "{", "mul_v2_fl", "(", "vec", "[", "a", "]", ",", "rad", ")", ";", "}", "uint", "vert_len", "=", "0", ";", "if", "(", "use_highlight", ")", "{", "vert_len", "+=", "(", "roundboxtype", "&", "UI_CNR_TOP_RIGHT", ")", "?", "6", ":", "1", ";", "vert_len", "+=", "(", "roundboxtype", "&", "UI_CNR_TOP_LEFT", ")", "?", "6", ":", "1", ";", "}", "if", "(", "use_highlight", "&&", "!", "use_shadow", ")", "{", "vert_len", "++", ";", "}", "else", "{", "vert_len", "+=", "(", "roundboxtype", "&", "UI_CNR_BOTTOM_RIGHT", ")", "?", "6", ":", "1", ";", "vert_len", "+=", "(", "roundboxtype", "&", "UI_CNR_BOTTOM_LEFT", ")", "?", "6", ":", "1", ";", "}", "float", "vbuf", "[", "24", "]", "[", "2", "]", ";", "uchar", "cbuf", "[", "24", "]", "[", "3", "]", ";", "int", "buf_index", "=", "0", ";", "if", "(", "use_highlight", ")", "{", "if", "(", "roundboxtype", "&", "UI_CNR_TOP_RIGHT", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", ",", "maxy", "-", "rad", ",", "col", ",", "&", "buf_index", ")", ";", "for", "(", "a", "=", "0", ";", "a", "<", "4", ";", "a", "++", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", "-", "vec", "[", "a", "]", "[", "1", "]", ",", "maxy", "-", "rad", "+", "vec", "[", "a", "]", "[", "0", "]", ",", "col", ",", "&", "buf_index", ")", ";", "}", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", "-", "rad", ",", "maxy", ",", "col", ",", "&", "buf_index", ")", ";", "}", "else", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", ",", "maxy", ",", "col", ",", "&", "buf_index", ")", ";", "}", "if", "(", "roundboxtype", "&", "UI_CNR_TOP_LEFT", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", "+", "rad", ",", "maxy", ",", "col", ",", "&", "buf_index", ")", ";", "for", "(", "a", "=", "0", ";", "a", "<", "4", ";", "a", "++", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", "+", "rad", "-", "vec", "[", "a", "]", "[", "0", "]", ",", "maxy", "-", "vec", "[", "a", "]", "[", "1", "]", ",", "col", ",", "&", "buf_index", ")", ";", "}", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", ",", "maxy", "-", "rad", ",", "col", ",", "&", "buf_index", ")", ";", "}", "else", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", ",", "maxy", ",", "col", ",", "&", "buf_index", ")", ";", "}", "}", "if", "(", "use_highlight", "&&", "!", "use_shadow", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", ",", "miny", "+", "rad", ",", "highlight_fade", "?", "col", ":", "highlight_fade", ",", "&", "buf_index", ")", ";", "}", "else", "{", "if", "(", "roundboxtype", "&", "UI_CNR_BOTTOM_LEFT", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", ",", "miny", "+", "rad", ",", "col", ",", "&", "buf_index", ")", ";", "for", "(", "a", "=", "0", ";", "a", "<", "4", ";", "a", "++", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", "+", "vec", "[", "a", "]", "[", "1", "]", ",", "miny", "+", "rad", "-", "vec", "[", "a", "]", "[", "0", "]", ",", "col", ",", "&", "buf_index", ")", ";", "}", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", "+", "rad", ",", "miny", ",", "col", ",", "&", "buf_index", ")", ";", "}", "else", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "minx", ",", "miny", ",", "col", ",", "&", "buf_index", ")", ";", "}", "if", "(", "roundboxtype", "&", "UI_CNR_BOTTOM_RIGHT", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", "-", "rad", ",", "miny", ",", "col", ",", "&", "buf_index", ")", ";", "for", "(", "a", "=", "0", ";", "a", "<", "4", ";", "a", "++", ")", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", "-", "rad", "+", "vec", "[", "a", "]", "[", "0", "]", ",", "miny", "+", "vec", "[", "a", "]", "[", "1", "]", ",", "col", ",", "&", "buf_index", ")", ";", "}", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", ",", "miny", "+", "rad", ",", "col", ",", "&", "buf_index", ")", ";", "}", "else", "{", "imm_buf_append", "(", "vbuf", ",", "cbuf", ",", "maxx", ",", "miny", ",", "col", ",", "&", "buf_index", ")", ";", "}", "}", "if", "(", "use_flip_x", ")", "{", "float", "midx", "=", "(", "minx", "+", "maxx", ")", "/", "2.0f", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "buf_index", ";", "i", "++", ")", "{", "vbuf", "[", "i", "]", "[", "0", "]", "=", "midx", "-", "(", "vbuf", "[", "i", "]", "[", "0", "]", "-", "midx", ")", ";", "}", "}", "GPUVertFormat", "*", "format", "=", "immVertexFormat", "(", ")", ";", "uint", "pos", "=", "GPU_vertformat_attr_add", "(", "format", ",", "\"", "\"", ",", "GPU_COMP_F32", ",", "2", ",", "GPU_FETCH_FLOAT", ")", ";", "uint", "color", "=", "GPU_vertformat_attr_add", "(", "format", ",", "\"", "\"", ",", "GPU_COMP_U8", ",", "3", ",", "GPU_FETCH_INT_TO_FLOAT_UNIT", ")", ";", "immBindBuiltinProgram", "(", "GPU_SHADER_2D_SMOOTH_COLOR", ")", ";", "immBegin", "(", "filled", "?", "GPU_PRIM_TRI_FAN", ":", "GPU_PRIM_LINE_STRIP", ",", "vert_len", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "buf_index", ";", "i", "++", ")", "{", "immAttr3ubv", "(", "color", ",", "cbuf", "[", "i", "]", ")", ";", "immVertex2fv", "(", "pos", ",", "vbuf", "[", "i", "]", ")", ";", "}", "immEnd", "(", ")", ";", "immUnbindProgram", "(", ")", ";", "}" ]
based on UI_draw_roundbox, check on making a version which allows us to skip some sides
[ "based", "on", "UI_draw_roundbox", "check", "on", "making", "a", "version", "which", "allows", "us", "to", "skip", "some", "sides" ]
[ "/* mult */", "/* Maximum size. */", "/* start with corner right-top */", "/* corner left-top */", "/* corner left-bottom */", "/* corner right-bottom */" ]
[ { "param": "filled", "type": "bool" }, { "param": "minx", "type": "float" }, { "param": "miny", "type": "float" }, { "param": "maxx", "type": "float" }, { "param": "maxy", "type": "float" }, { "param": "rad", "type": "float" }, { "param": "roundboxtype", "type": "int" }, { "param": "use_highlight", "type": "bool" }, { "param": "use_shadow", "type": "bool" }, { "param": "use_flip_x", "type": "bool" }, { "param": "highlight_fade", "type": "uchar" }, { "param": "col", "type": "uchar" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "filled", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "minx", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "miny", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "maxx", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "maxy", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rad", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "roundboxtype", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_highlight", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_shadow", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_flip_x", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "highlight_fade", "type": "uchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "col", "type": "uchar", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
ui_handler_panel_region
int
int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, const uiBut *active_but) { uiBlock *block; Panel *pa; int retval, mx, my; bool has_category_tabs = UI_panel_category_is_visible(ar); retval = WM_UI_HANDLER_CONTINUE; /* Scrollbars can overlap panels now, they have handling priority. */ if (UI_view2d_mouse_in_scrollers(ar, &ar->v2d, event->x, event->y)) { return retval; } /* handle category tabs */ if (has_category_tabs) { if (event->val == KM_PRESS) { if (event->type == LEFTMOUSE) { PanelCategoryDyn *pc_dyn = UI_panel_category_find_mouse_over(ar, event); if (pc_dyn) { UI_panel_category_active_set(ar, pc_dyn->idname); ED_region_tag_redraw(ar); /* reset scroll to the top [#38348] */ UI_view2d_offset(&ar->v2d, -1.0f, 1.0f); retval = WM_UI_HANDLER_BREAK; } } else if ((event->type == TABKEY && event->ctrl) || ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { /* cycle tabs */ retval = ui_handle_panel_category_cycling(event, ar, active_but); } } } if (retval == WM_UI_HANDLER_BREAK) { return retval; } for (block = ar->uiblocks.last; block; block = block->prev) { uiPanelMouseState mouse_state; mx = event->x; my = event->y; ui_window_to_block(ar, block, &mx, &my); /* checks for mouse position inside */ pa = block->panel; if (!pa) { continue; } /* XXX - accessed freed panels when scripts reload, need to fix. */ if (pa->type && pa->type->flag & PNL_NO_HEADER) { continue; } mouse_state = ui_panel_mouse_state_get(block, pa, mx, my); /* XXX hardcoded key warning */ if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) { if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) { if (pa->flag & PNL_CLOSEDY) { if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); } } else { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); } retval = WM_UI_HANDLER_BREAK; continue; } } /* on active button, do not handle panels */ if (ui_region_find_active_but(ar) != NULL) { continue; } if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) { if (event->val == KM_PRESS) { /* open close on header */ if (ELEM(event->type, RETKEY, PADENTER)) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_handle_panel_header(C, block, mx, my, RETKEY, event->ctrl, event->shift); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == LEFTMOUSE) { /* all inside clicks should return in break - overlapping/float panels */ retval = WM_UI_HANDLER_BREAK; if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); retval = WM_UI_HANDLER_BREAK; break; } else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) { panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == RIGHTMOUSE) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_popup_context_menu_for_panel(C, ar, block->panel); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == ESCKEY) { /*XXX 2.50*/ #if 0 if (block->handler) { rem_blockhandler(sa, block->handler); ED_region_tag_redraw(ar); retval = WM_UI_HANDLER_BREAK; } #endif } else if (event->type == PADPLUSKEY || event->type == PADMINUS) { #if 0 /* XXX make float panel exception? */ int zoom = 0; /* if panel is closed, only zoom if mouse is over the header */ if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { if (inside_header) { zoom = 1; } } else { zoom = 1; } if (zoom) { ScrArea *sa = CTX_wm_area(C); SpaceLink *sl = sa->spacedata.first; if (sa->spacetype != SPACE_PROPERTIES) { if (!(pa->control & UI_PNL_SCALE)) { if (event->type == PADPLUSKEY) { sl->blockscale += 0.1; } else { sl->blockscale -= 0.1; } CLAMP(sl->blockscale, 0.6, 1.0); ED_region_tag_redraw(ar); retval = WM_UI_HANDLER_BREAK; } } } #endif } } } } return retval; }
/* XXX should become modal keymap */ /* AKey is opening/closing panels, independent of button state now */
XXX should become modal keymap AKey is opening/closing panels, independent of button state now
[ "XXX", "should", "become", "modal", "keymap", "AKey", "is", "opening", "/", "closing", "panels", "independent", "of", "button", "state", "now" ]
int ui_handler_panel_region(bContext *C, const wmEvent *event, ARegion *ar, const uiBut *active_but) { uiBlock *block; Panel *pa; int retval, mx, my; bool has_category_tabs = UI_panel_category_is_visible(ar); retval = WM_UI_HANDLER_CONTINUE; if (UI_view2d_mouse_in_scrollers(ar, &ar->v2d, event->x, event->y)) { return retval; } if (has_category_tabs) { if (event->val == KM_PRESS) { if (event->type == LEFTMOUSE) { PanelCategoryDyn *pc_dyn = UI_panel_category_find_mouse_over(ar, event); if (pc_dyn) { UI_panel_category_active_set(ar, pc_dyn->idname); ED_region_tag_redraw(ar); UI_view2d_offset(&ar->v2d, -1.0f, 1.0f); retval = WM_UI_HANDLER_BREAK; } } else if ((event->type == TABKEY && event->ctrl) || ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { retval = ui_handle_panel_category_cycling(event, ar, active_but); } } } if (retval == WM_UI_HANDLER_BREAK) { return retval; } for (block = ar->uiblocks.last; block; block = block->prev) { uiPanelMouseState mouse_state; mx = event->x; my = event->y; ui_window_to_block(ar, block, &mx, &my); pa = block->panel; if (!pa) { continue; } if (pa->type && pa->type->flag & PNL_NO_HEADER) { continue; } mouse_state = ui_panel_mouse_state_get(block, pa, mx, my); if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER) && event->val == KM_PRESS) { if (event->type == AKEY && ((event->ctrl + event->oskey + event->shift + event->alt) == 0)) { if (pa->flag & PNL_CLOSEDY) { if ((block->rect.ymax <= my) && (block->rect.ymax + PNL_HEADER >= my)) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); } } else { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); } retval = WM_UI_HANDLER_BREAK; continue; } } if (ui_region_find_active_but(ar) != NULL) { continue; } if (ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) { if (event->val == KM_PRESS) { if (ELEM(event->type, RETKEY, PADENTER)) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_handle_panel_header(C, block, mx, my, RETKEY, event->ctrl, event->shift); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == LEFTMOUSE) { retval = WM_UI_HANDLER_BREAK; if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_handle_panel_header(C, block, mx, my, event->type, event->ctrl, event->shift); retval = WM_UI_HANDLER_BREAK; break; } else if ((mouse_state == PANEL_MOUSE_INSIDE_SCALE) && !(pa->flag & PNL_CLOSED)) { panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == RIGHTMOUSE) { if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) { ui_popup_context_menu_for_panel(C, ar, block->panel); retval = WM_UI_HANDLER_BREAK; break; } } else if (event->type == ESCKEY) { #if 0 if (block->handler) { rem_blockhandler(sa, block->handler); ED_region_tag_redraw(ar); retval = WM_UI_HANDLER_BREAK; } #endif } else if (event->type == PADPLUSKEY || event->type == PADMINUS) { #if 0 int zoom = 0; if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) { if (inside_header) { zoom = 1; } } else { zoom = 1; } if (zoom) { ScrArea *sa = CTX_wm_area(C); SpaceLink *sl = sa->spacedata.first; if (sa->spacetype != SPACE_PROPERTIES) { if (!(pa->control & UI_PNL_SCALE)) { if (event->type == PADPLUSKEY) { sl->blockscale += 0.1; } else { sl->blockscale -= 0.1; } CLAMP(sl->blockscale, 0.6, 1.0); ED_region_tag_redraw(ar); retval = WM_UI_HANDLER_BREAK; } } } #endif } } } } return retval; }
[ "int", "ui_handler_panel_region", "(", "bContext", "*", "C", ",", "const", "wmEvent", "*", "event", ",", "ARegion", "*", "ar", ",", "const", "uiBut", "*", "active_but", ")", "{", "uiBlock", "*", "block", ";", "Panel", "*", "pa", ";", "int", "retval", ",", "mx", ",", "my", ";", "bool", "has_category_tabs", "=", "UI_panel_category_is_visible", "(", "ar", ")", ";", "retval", "=", "WM_UI_HANDLER_CONTINUE", ";", "if", "(", "UI_view2d_mouse_in_scrollers", "(", "ar", ",", "&", "ar", "->", "v2d", ",", "event", "->", "x", ",", "event", "->", "y", ")", ")", "{", "return", "retval", ";", "}", "if", "(", "has_category_tabs", ")", "{", "if", "(", "event", "->", "val", "==", "KM_PRESS", ")", "{", "if", "(", "event", "->", "type", "==", "LEFTMOUSE", ")", "{", "PanelCategoryDyn", "*", "pc_dyn", "=", "UI_panel_category_find_mouse_over", "(", "ar", ",", "event", ")", ";", "if", "(", "pc_dyn", ")", "{", "UI_panel_category_active_set", "(", "ar", ",", "pc_dyn", "->", "idname", ")", ";", "ED_region_tag_redraw", "(", "ar", ")", ";", "UI_view2d_offset", "(", "&", "ar", "->", "v2d", ",", "-1.0f", ",", "1.0f", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "}", "}", "else", "if", "(", "(", "event", "->", "type", "==", "TABKEY", "&&", "event", "->", "ctrl", ")", "||", "ELEM", "(", "event", "->", "type", ",", "WHEELUPMOUSE", ",", "WHEELDOWNMOUSE", ")", ")", "{", "retval", "=", "ui_handle_panel_category_cycling", "(", "event", ",", "ar", ",", "active_but", ")", ";", "}", "}", "}", "if", "(", "retval", "==", "WM_UI_HANDLER_BREAK", ")", "{", "return", "retval", ";", "}", "for", "(", "block", "=", "ar", "->", "uiblocks", ".", "last", ";", "block", ";", "block", "=", "block", "->", "prev", ")", "{", "uiPanelMouseState", "mouse_state", ";", "mx", "=", "event", "->", "x", ";", "my", "=", "event", "->", "y", ";", "ui_window_to_block", "(", "ar", ",", "block", ",", "&", "mx", ",", "&", "my", ")", ";", "pa", "=", "block", "->", "panel", ";", "if", "(", "!", "pa", ")", "{", "continue", ";", "}", "if", "(", "pa", "->", "type", "&&", "pa", "->", "type", "->", "flag", "&", "PNL_NO_HEADER", ")", "{", "continue", ";", "}", "mouse_state", "=", "ui_panel_mouse_state_get", "(", "block", ",", "pa", ",", "mx", ",", "my", ")", ";", "if", "(", "ELEM", "(", "mouse_state", ",", "PANEL_MOUSE_INSIDE_CONTENT", ",", "PANEL_MOUSE_INSIDE_HEADER", ")", "&&", "event", "->", "val", "==", "KM_PRESS", ")", "{", "if", "(", "event", "->", "type", "==", "AKEY", "&&", "(", "(", "event", "->", "ctrl", "+", "event", "->", "oskey", "+", "event", "->", "shift", "+", "event", "->", "alt", ")", "==", "0", ")", ")", "{", "if", "(", "pa", "->", "flag", "&", "PNL_CLOSEDY", ")", "{", "if", "(", "(", "block", "->", "rect", ".", "ymax", "<=", "my", ")", "&&", "(", "block", "->", "rect", ".", "ymax", "+", "PNL_HEADER", ">=", "my", ")", ")", "{", "ui_handle_panel_header", "(", "C", ",", "block", ",", "mx", ",", "my", ",", "event", "->", "type", ",", "event", "->", "ctrl", ",", "event", "->", "shift", ")", ";", "}", "}", "else", "{", "ui_handle_panel_header", "(", "C", ",", "block", ",", "mx", ",", "my", ",", "event", "->", "type", ",", "event", "->", "ctrl", ",", "event", "->", "shift", ")", ";", "}", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "continue", ";", "}", "}", "if", "(", "ui_region_find_active_but", "(", "ar", ")", "!=", "NULL", ")", "{", "continue", ";", "}", "if", "(", "ELEM", "(", "mouse_state", ",", "PANEL_MOUSE_INSIDE_CONTENT", ",", "PANEL_MOUSE_INSIDE_HEADER", ")", ")", "{", "if", "(", "event", "->", "val", "==", "KM_PRESS", ")", "{", "if", "(", "ELEM", "(", "event", "->", "type", ",", "RETKEY", ",", "PADENTER", ")", ")", "{", "if", "(", "mouse_state", "==", "PANEL_MOUSE_INSIDE_HEADER", ")", "{", "ui_handle_panel_header", "(", "C", ",", "block", ",", "mx", ",", "my", ",", "RETKEY", ",", "event", "->", "ctrl", ",", "event", "->", "shift", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "break", ";", "}", "}", "else", "if", "(", "event", "->", "type", "==", "LEFTMOUSE", ")", "{", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "if", "(", "mouse_state", "==", "PANEL_MOUSE_INSIDE_HEADER", ")", "{", "ui_handle_panel_header", "(", "C", ",", "block", ",", "mx", ",", "my", ",", "event", "->", "type", ",", "event", "->", "ctrl", ",", "event", "->", "shift", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "break", ";", "}", "else", "if", "(", "(", "mouse_state", "==", "PANEL_MOUSE_INSIDE_SCALE", ")", "&&", "!", "(", "pa", "->", "flag", "&", "PNL_CLOSED", ")", ")", "{", "panel_activate_state", "(", "C", ",", "pa", ",", "PANEL_STATE_DRAG_SCALE", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "break", ";", "}", "}", "else", "if", "(", "event", "->", "type", "==", "RIGHTMOUSE", ")", "{", "if", "(", "mouse_state", "==", "PANEL_MOUSE_INSIDE_HEADER", ")", "{", "ui_popup_context_menu_for_panel", "(", "C", ",", "ar", ",", "block", "->", "panel", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "break", ";", "}", "}", "else", "if", "(", "event", "->", "type", "==", "ESCKEY", ")", "{", "#if", "0", "\n", "if", "(", "block", "->", "handler", ")", "{", "rem_blockhandler", "(", "sa", ",", "block", "->", "handler", ")", ";", "ED_region_tag_redraw", "(", "ar", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "}", "#endif", "}", "else", "if", "(", "event", "->", "type", "==", "PADPLUSKEY", "||", "event", "->", "type", "==", "PADMINUS", ")", "{", "#if", "0", "\n", "int", "zoom", "=", "0", ";", "if", "(", "pa", "->", "flag", "&", "(", "PNL_CLOSEDX", "|", "PNL_CLOSEDY", ")", ")", "{", "if", "(", "inside_header", ")", "{", "zoom", "=", "1", ";", "}", "}", "else", "{", "zoom", "=", "1", ";", "}", "if", "(", "zoom", ")", "{", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "SpaceLink", "*", "sl", "=", "sa", "->", "spacedata", ".", "first", ";", "if", "(", "sa", "->", "spacetype", "!=", "SPACE_PROPERTIES", ")", "{", "if", "(", "!", "(", "pa", "->", "control", "&", "UI_PNL_SCALE", ")", ")", "{", "if", "(", "event", "->", "type", "==", "PADPLUSKEY", ")", "{", "sl", "->", "blockscale", "+=", "0.1", ";", "}", "else", "{", "sl", "->", "blockscale", "-=", "0.1", ";", "}", "CLAMP", "(", "sl", "->", "blockscale", ",", "0.6", ",", "1.0", ")", ";", "ED_region_tag_redraw", "(", "ar", ")", ";", "retval", "=", "WM_UI_HANDLER_BREAK", ";", "}", "}", "}", "#endif", "}", "}", "}", "}", "return", "retval", ";", "}" ]
XXX should become modal keymap AKey is opening/closing panels, independent of button state now
[ "XXX", "should", "become", "modal", "keymap", "AKey", "is", "opening", "/", "closing", "panels", "independent", "of", "button", "state", "now" ]
[ "/* Scrollbars can overlap panels now, they have handling priority. */", "/* handle category tabs */", "/* reset scroll to the top [#38348] */", "/* cycle tabs */", "/* checks for mouse position inside */", "/* XXX - accessed freed panels when scripts reload, need to fix. */", "/* XXX hardcoded key warning */", "/* on active button, do not handle panels */", "/* open close on header */", "/* all inside clicks should return in break - overlapping/float panels */", "/*XXX 2.50*/", "/* XXX make float panel exception? */", "/* if panel is closed, only zoom if mouse is over the header */" ]
[ { "param": "C", "type": "bContext" }, { "param": "event", "type": "wmEvent" }, { "param": "ar", "type": "ARegion" }, { "param": "active_but", "type": "uiBut" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "wmEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ar", "type": "ARegion", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "active_but", "type": "uiBut", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8adb82a22c8739ade530a512e7108e9bee993217
DemonRem/blender
source/blender/editors/interface/interface_panel.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
ui_handler_panel
int
static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) { Panel *panel = userdata; uiHandlePanelData *data = panel->activedata; /* verify if we can stop */ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); int align = panel_aligned(sa, ar); if (align) { panel_activate_state(C, panel, PANEL_STATE_ANIMATION); } else { panel_activate_state(C, panel, PANEL_STATE_EXIT); } } else if (event->type == MOUSEMOVE) { if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); } } else if (event->type == TIMER && event->customdata == data->animtimer) { if (data->state == PANEL_STATE_ANIMATION) { ui_do_animate(C, panel); } else if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); } } data = panel->activedata; if (data && data->state == PANEL_STATE_ANIMATION) { return WM_UI_HANDLER_CONTINUE; } else { return WM_UI_HANDLER_BREAK; } }
/* note, this is modal handler and should not swallow events for animation */
note, this is modal handler and should not swallow events for animation
[ "note", "this", "is", "modal", "handler", "and", "should", "not", "swallow", "events", "for", "animation" ]
static int ui_handler_panel(bContext *C, const wmEvent *event, void *userdata) { Panel *panel = userdata; uiHandlePanelData *data = panel->activedata; if (event->type == LEFTMOUSE && event->val == KM_RELEASE) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); int align = panel_aligned(sa, ar); if (align) { panel_activate_state(C, panel, PANEL_STATE_ANIMATION); } else { panel_activate_state(C, panel, PANEL_STATE_EXIT); } } else if (event->type == MOUSEMOVE) { if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); } } else if (event->type == TIMER && event->customdata == data->animtimer) { if (data->state == PANEL_STATE_ANIMATION) { ui_do_animate(C, panel); } else if (data->state == PANEL_STATE_DRAG) { ui_do_drag(C, event, panel); } } data = panel->activedata; if (data && data->state == PANEL_STATE_ANIMATION) { return WM_UI_HANDLER_CONTINUE; } else { return WM_UI_HANDLER_BREAK; } }
[ "static", "int", "ui_handler_panel", "(", "bContext", "*", "C", ",", "const", "wmEvent", "*", "event", ",", "void", "*", "userdata", ")", "{", "Panel", "*", "panel", "=", "userdata", ";", "uiHandlePanelData", "*", "data", "=", "panel", "->", "activedata", ";", "if", "(", "event", "->", "type", "==", "LEFTMOUSE", "&&", "event", "->", "val", "==", "KM_RELEASE", ")", "{", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "ARegion", "*", "ar", "=", "CTX_wm_region", "(", "C", ")", ";", "int", "align", "=", "panel_aligned", "(", "sa", ",", "ar", ")", ";", "if", "(", "align", ")", "{", "panel_activate_state", "(", "C", ",", "panel", ",", "PANEL_STATE_ANIMATION", ")", ";", "}", "else", "{", "panel_activate_state", "(", "C", ",", "panel", ",", "PANEL_STATE_EXIT", ")", ";", "}", "}", "else", "if", "(", "event", "->", "type", "==", "MOUSEMOVE", ")", "{", "if", "(", "data", "->", "state", "==", "PANEL_STATE_DRAG", ")", "{", "ui_do_drag", "(", "C", ",", "event", ",", "panel", ")", ";", "}", "}", "else", "if", "(", "event", "->", "type", "==", "TIMER", "&&", "event", "->", "customdata", "==", "data", "->", "animtimer", ")", "{", "if", "(", "data", "->", "state", "==", "PANEL_STATE_ANIMATION", ")", "{", "ui_do_animate", "(", "C", ",", "panel", ")", ";", "}", "else", "if", "(", "data", "->", "state", "==", "PANEL_STATE_DRAG", ")", "{", "ui_do_drag", "(", "C", ",", "event", ",", "panel", ")", ";", "}", "}", "data", "=", "panel", "->", "activedata", ";", "if", "(", "data", "&&", "data", "->", "state", "==", "PANEL_STATE_ANIMATION", ")", "{", "return", "WM_UI_HANDLER_CONTINUE", ";", "}", "else", "{", "return", "WM_UI_HANDLER_BREAK", ";", "}", "}" ]
note, this is modal handler and should not swallow events for animation
[ "note", "this", "is", "modal", "handler", "and", "should", "not", "swallow", "events", "for", "animation" ]
[ "/* verify if we can stop */" ]
[ { "param": "C", "type": "bContext" }, { "param": "event", "type": "wmEvent" }, { "param": "userdata", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "wmEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "userdata", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ddc7f9ee4c7844aa43a3a2968bfee5b0e711d2fd
DemonRem/blender
source/blender/blenlib/intern/boxpack_2d.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
box_areasort
int
static int box_areasort(const void *p1, const void *p2) { const BoxPack *b1 = p1, *b2 = p2; const float a1 = box_area(b1); const float a2 = box_area(b2); if (a1 < a2) { return 1; } else if (a1 > a2) { return -1; } return 0; }
/* qsort function - sort largest to smallest */
qsort function - sort largest to smallest
[ "qsort", "function", "-", "sort", "largest", "to", "smallest" ]
static int box_areasort(const void *p1, const void *p2) { const BoxPack *b1 = p1, *b2 = p2; const float a1 = box_area(b1); const float a2 = box_area(b2); if (a1 < a2) { return 1; } else if (a1 > a2) { return -1; } return 0; }
[ "static", "int", "box_areasort", "(", "const", "void", "*", "p1", ",", "const", "void", "*", "p2", ")", "{", "const", "BoxPack", "*", "b1", "=", "p1", ",", "*", "b2", "=", "p2", ";", "const", "float", "a1", "=", "box_area", "(", "b1", ")", ";", "const", "float", "a2", "=", "box_area", "(", "b2", ")", ";", "if", "(", "a1", "<", "a2", ")", "{", "return", "1", ";", "}", "else", "if", "(", "a1", ">", "a2", ")", "{", "return", "-1", ";", "}", "return", "0", ";", "}" ]
qsort function - sort largest to smallest
[ "qsort", "function", "-", "sort", "largest", "to", "smallest" ]
[]
[ { "param": "p1", "type": "void" }, { "param": "p2", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "p1", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "p2", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9e3f91bc9719995e9195f2b6c9bd58b05b9e9f2e
DemonRem/blender
source/blender/editors/animation/anim_ops.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
change_frame_poll
bool
static bool change_frame_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); /* XXX temp? prevent changes during render */ if (G.is_rendering) { return false; } /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION, * this shouldn't show up in 3D editor (or others without 2D timeline view) via search */ if (sa) { if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { return true; } else if (sa->spacetype == SPACE_GRAPH) { /* NOTE: Graph Editor has special version which does some extra stuff. * No need to show the generic error message for that case though! */ return false; } } CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active"); return false; }
/* Check if the operator can be run from the current context */
Check if the operator can be run from the current context
[ "Check", "if", "the", "operator", "can", "be", "run", "from", "the", "current", "context" ]
static bool change_frame_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); if (G.is_rendering) { return false; } if (sa) { if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_SEQ, SPACE_CLIP)) { return true; } else if (sa->spacetype == SPACE_GRAPH) { return false; } } CTX_wm_operator_poll_msg_set(C, "Expected an animation area to be active"); return false; }
[ "static", "bool", "change_frame_poll", "(", "bContext", "*", "C", ")", "{", "ScrArea", "*", "sa", "=", "CTX_wm_area", "(", "C", ")", ";", "if", "(", "G", ".", "is_rendering", ")", "{", "return", "false", ";", "}", "if", "(", "sa", ")", "{", "if", "(", "ELEM", "(", "sa", "->", "spacetype", ",", "SPACE_ACTION", ",", "SPACE_NLA", ",", "SPACE_SEQ", ",", "SPACE_CLIP", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "sa", "->", "spacetype", "==", "SPACE_GRAPH", ")", "{", "return", "false", ";", "}", "}", "CTX_wm_operator_poll_msg_set", "(", "C", ",", "\"", "\"", ")", ";", "return", "false", ";", "}" ]
Check if the operator can be run from the current context
[ "Check", "if", "the", "operator", "can", "be", "run", "from", "the", "current", "context" ]
[ "/* XXX temp? prevent changes during render */", "/* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION,\n * this shouldn't show up in 3D editor (or others without 2D timeline view) via search\n */", "/* NOTE: Graph Editor has special version which does some extra stuff.\n * No need to show the generic error message for that case though!\n */" ]
[ { "param": "C", "type": "bContext" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9e3f91bc9719995e9195f2b6c9bd58b05b9e9f2e
DemonRem/blender
source/blender/editors/animation/anim_ops.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
change_frame_modal
int
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ switch (event->type) { case ESCKEY: ret = OPERATOR_FINISHED; break; case MOUSEMOVE: RNA_float_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); break; case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: /* We check for either mouse-button to end, to work with all user keymaps. */ if (event->val == KM_RELEASE) { ret = OPERATOR_FINISHED; } break; case LEFTCTRLKEY: case RIGHTCTRLKEY: if (event->val == KM_RELEASE) { RNA_boolean_set(op->ptr, "snap", false); } else if (event->val == KM_PRESS) { RNA_boolean_set(op->ptr, "snap", true); } break; } if (ret != OPERATOR_RUNNING_MODAL) { change_frame_seq_preview_end(C); } return ret; }
/* Modal event handling of frame changing */
Modal event handling of frame changing
[ "Modal", "event", "handling", "of", "frame", "changing" ]
static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { int ret = OPERATOR_RUNNING_MODAL; switch (event->type) { case ESCKEY: ret = OPERATOR_FINISHED; break; case MOUSEMOVE: RNA_float_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); break; case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: if (event->val == KM_RELEASE) { ret = OPERATOR_FINISHED; } break; case LEFTCTRLKEY: case RIGHTCTRLKEY: if (event->val == KM_RELEASE) { RNA_boolean_set(op->ptr, "snap", false); } else if (event->val == KM_PRESS) { RNA_boolean_set(op->ptr, "snap", true); } break; } if (ret != OPERATOR_RUNNING_MODAL) { change_frame_seq_preview_end(C); } return ret; }
[ "static", "int", "change_frame_modal", "(", "bContext", "*", "C", ",", "wmOperator", "*", "op", ",", "const", "wmEvent", "*", "event", ")", "{", "int", "ret", "=", "OPERATOR_RUNNING_MODAL", ";", "switch", "(", "event", "->", "type", ")", "{", "case", "ESCKEY", ":", "ret", "=", "OPERATOR_FINISHED", ";", "break", ";", "case", "MOUSEMOVE", ":", "RNA_float_set", "(", "op", "->", "ptr", ",", "\"", "\"", ",", "frame_from_event", "(", "C", ",", "event", ")", ")", ";", "change_frame_apply", "(", "C", ",", "op", ")", ";", "break", ";", "case", "LEFTMOUSE", ":", "case", "RIGHTMOUSE", ":", "case", "MIDDLEMOUSE", ":", "if", "(", "event", "->", "val", "==", "KM_RELEASE", ")", "{", "ret", "=", "OPERATOR_FINISHED", ";", "}", "break", ";", "case", "LEFTCTRLKEY", ":", "case", "RIGHTCTRLKEY", ":", "if", "(", "event", "->", "val", "==", "KM_RELEASE", ")", "{", "RNA_boolean_set", "(", "op", "->", "ptr", ",", "\"", "\"", ",", "false", ")", ";", "}", "else", "if", "(", "event", "->", "val", "==", "KM_PRESS", ")", "{", "RNA_boolean_set", "(", "op", "->", "ptr", ",", "\"", "\"", ",", "true", ")", ";", "}", "break", ";", "}", "if", "(", "ret", "!=", "OPERATOR_RUNNING_MODAL", ")", "{", "change_frame_seq_preview_end", "(", "C", ")", ";", "}", "return", "ret", ";", "}" ]
Modal event handling of frame changing
[ "Modal", "event", "handling", "of", "frame", "changing" ]
[ "/* execute the events */", "/* We check for either mouse-button to end, to work with all user keymaps. */" ]
[ { "param": "C", "type": "bContext" }, { "param": "op", "type": "wmOperator" }, { "param": "event", "type": "wmEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "wmOperator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "wmEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e3e7168330d5f38c7950e8047e411e352dc4236a
DemonRem/blender
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
reduce_stroke_points
void
static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eBuildGpencil_Transition transition) { bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__); MDeformVert *new_dvert = NULL; if (gps->dvert != NULL) { new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); } /* Which end should points be removed from */ // TODO: free stroke weights switch (transition) { case GP_BUILD_TRANSITION_GROW: /* Show in forward order = * Remove ungrown-points from end of stroke. */ case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order = * Remove dead-points from end of stroke. */ { /* copy over point data */ memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points); if (gps->dvert != NULL) { memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); /* free unused point weights */ for (int i = num_points; i < gps->totpoints; i++) { MDeformVert *dvert = &gps->dvert[i]; BKE_gpencil_free_point_weights(dvert); } } break; } /* Hide in forward order = Remove points from start of stroke */ case GP_BUILD_TRANSITION_FADE: { /* num_points is the number of points left after reducing. * We need to know how many to remove */ const int offset = gps->totpoints - num_points; /* copy over point data */ memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points); if (gps->dvert != NULL) { memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); /* free unused weights */ for (int i = 0; i < offset; i++) { MDeformVert *dvert = &gps->dvert[i]; BKE_gpencil_free_point_weights(dvert); } } break; } default: printf("ERROR: Unknown transition %d in %s()\n", (int)transition, __func__); break; } /* replace stroke geometry */ MEM_SAFE_FREE(gps->points); MEM_SAFE_FREE(gps->dvert); gps->points = new_points; gps->dvert = new_dvert; gps->totpoints = num_points; /* mark stroke as needing to have its geometry caches rebuilt */ gps->flag |= GP_STROKE_RECALC_GEOMETRY; gps->tot_triangles = 0; MEM_SAFE_FREE(gps->triangles); }
/* Reduce the number of points in the stroke * * Note: This won't be called if all points are present/removed * TODO: Allow blending of growing/shrinking tip (e.g. for more gradual transitions) */
Reduce the number of points in the stroke Note: This won't be called if all points are present/removed TODO: Allow blending of growing/shrinking tip
[ "Reduce", "the", "number", "of", "points", "in", "the", "stroke", "Note", ":", "This", "won", "'", "t", "be", "called", "if", "all", "points", "are", "present", "/", "removed", "TODO", ":", "Allow", "blending", "of", "growing", "/", "shrinking", "tip" ]
static void reduce_stroke_points(bGPDstroke *gps, const int num_points, const eBuildGpencil_Transition transition) { bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__); MDeformVert *new_dvert = NULL; if (gps->dvert != NULL) { new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__); } switch (transition) { case GP_BUILD_TRANSITION_GROW: case GP_BUILD_TRANSITION_SHRINK: { memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points); if (gps->dvert != NULL) { memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points); for (int i = num_points; i < gps->totpoints; i++) { MDeformVert *dvert = &gps->dvert[i]; BKE_gpencil_free_point_weights(dvert); } } break; } case GP_BUILD_TRANSITION_FADE: { const int offset = gps->totpoints - num_points; memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points); if (gps->dvert != NULL) { memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points); for (int i = 0; i < offset; i++) { MDeformVert *dvert = &gps->dvert[i]; BKE_gpencil_free_point_weights(dvert); } } break; } default: printf("ERROR: Unknown transition %d in %s()\n", (int)transition, __func__); break; } MEM_SAFE_FREE(gps->points); MEM_SAFE_FREE(gps->dvert); gps->points = new_points; gps->dvert = new_dvert; gps->totpoints = num_points; gps->flag |= GP_STROKE_RECALC_GEOMETRY; gps->tot_triangles = 0; MEM_SAFE_FREE(gps->triangles); }
[ "static", "void", "reduce_stroke_points", "(", "bGPDstroke", "*", "gps", ",", "const", "int", "num_points", ",", "const", "eBuildGpencil_Transition", "transition", ")", "{", "bGPDspoint", "*", "new_points", "=", "MEM_callocN", "(", "sizeof", "(", "bGPDspoint", ")", "*", "num_points", ",", "__func__", ")", ";", "MDeformVert", "*", "new_dvert", "=", "NULL", ";", "if", "(", "gps", "->", "dvert", "!=", "NULL", ")", "{", "new_dvert", "=", "MEM_callocN", "(", "sizeof", "(", "MDeformVert", ")", "*", "num_points", ",", "__func__", ")", ";", "}", "switch", "(", "transition", ")", "{", "case", "GP_BUILD_TRANSITION_GROW", ":", "case", "GP_BUILD_TRANSITION_SHRINK", ":", "{", "memcpy", "(", "new_points", ",", "gps", "->", "points", ",", "sizeof", "(", "bGPDspoint", ")", "*", "num_points", ")", ";", "if", "(", "gps", "->", "dvert", "!=", "NULL", ")", "{", "memcpy", "(", "new_dvert", ",", "gps", "->", "dvert", ",", "sizeof", "(", "MDeformVert", ")", "*", "num_points", ")", ";", "for", "(", "int", "i", "=", "num_points", ";", "i", "<", "gps", "->", "totpoints", ";", "i", "++", ")", "{", "MDeformVert", "*", "dvert", "=", "&", "gps", "->", "dvert", "[", "i", "]", ";", "BKE_gpencil_free_point_weights", "(", "dvert", ")", ";", "}", "}", "break", ";", "}", "case", "GP_BUILD_TRANSITION_FADE", ":", "{", "const", "int", "offset", "=", "gps", "->", "totpoints", "-", "num_points", ";", "memcpy", "(", "new_points", ",", "gps", "->", "points", "+", "offset", ",", "sizeof", "(", "bGPDspoint", ")", "*", "num_points", ")", ";", "if", "(", "gps", "->", "dvert", "!=", "NULL", ")", "{", "memcpy", "(", "new_dvert", ",", "gps", "->", "dvert", "+", "offset", ",", "sizeof", "(", "MDeformVert", ")", "*", "num_points", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "offset", ";", "i", "++", ")", "{", "MDeformVert", "*", "dvert", "=", "&", "gps", "->", "dvert", "[", "i", "]", ";", "BKE_gpencil_free_point_weights", "(", "dvert", ")", ";", "}", "}", "break", ";", "}", "default", ":", "printf", "(", "\"", "\\n", "\"", ",", "(", "int", ")", "transition", ",", "__func__", ")", ";", "break", ";", "}", "MEM_SAFE_FREE", "(", "gps", "->", "points", ")", ";", "MEM_SAFE_FREE", "(", "gps", "->", "dvert", ")", ";", "gps", "->", "points", "=", "new_points", ";", "gps", "->", "dvert", "=", "new_dvert", ";", "gps", "->", "totpoints", "=", "num_points", ";", "gps", "->", "flag", "|=", "GP_STROKE_RECALC_GEOMETRY", ";", "gps", "->", "tot_triangles", "=", "0", ";", "MEM_SAFE_FREE", "(", "gps", "->", "triangles", ")", ";", "}" ]
Reduce the number of points in the stroke Note: This won't be called if all points are present/removed TODO: Allow blending of growing/shrinking tip (e.g.
[ "Reduce", "the", "number", "of", "points", "in", "the", "stroke", "Note", ":", "This", "won", "'", "t", "be", "called", "if", "all", "points", "are", "present", "/", "removed", "TODO", ":", "Allow", "blending", "of", "growing", "/", "shrinking", "tip", "(", "e", ".", "g", "." ]
[ "/* Which end should points be removed from */", "// TODO: free stroke weights", "/* Show in forward order =\n * Remove ungrown-points from end of stroke. */", "/* Hide in reverse order =\n * Remove dead-points from end of stroke. */", "/* copy over point data */", "/* free unused point weights */", "/* Hide in forward order = Remove points from start of stroke */", "/* num_points is the number of points left after reducing.\n * We need to know how many to remove\n */", "/* copy over point data */", "/* free unused weights */", "/* replace stroke geometry */", "/* mark stroke as needing to have its geometry caches rebuilt */" ]
[ { "param": "gps", "type": "bGPDstroke" }, { "param": "num_points", "type": "int" }, { "param": "transition", "type": "eBuildGpencil_Transition" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num_points", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "transition", "type": "eBuildGpencil_Transition", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e3e7168330d5f38c7950e8047e411e352dc4236a
DemonRem/blender
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
build_sequential
void
static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac) { const size_t tot_strokes = BLI_listbase_count(&gpf->strokes); bGPDstroke *gps; size_t i; /* 1) Compute proportion of time each stroke should occupy */ /* NOTE: This assumes that the total number of points won't overflow! */ tStrokeBuildDetails *table = MEM_callocN(sizeof(tStrokeBuildDetails) * tot_strokes, __func__); size_t totpoints = 0; /* 1.1) First pass - Tally up points */ for (gps = gpf->strokes.first, i = 0; gps; gps = gps->next, i++) { tStrokeBuildDetails *cell = &table[i]; cell->gps = gps; cell->totpoints = gps->totpoints; totpoints += cell->totpoints; } /* 1.2) Second pass - Compute the overall indices for points */ for (i = 0; i < tot_strokes; i++) { tStrokeBuildDetails *cell = &table[i]; if (i == 0) { cell->start_idx = 0; } else { cell->start_idx = (cell - 1)->end_idx; } cell->end_idx = cell->start_idx + cell->totpoints - 1; } /* 2) Determine the global indices for points that should be visible */ size_t first_visible = 0; size_t last_visible = 0; switch (mmd->transition) { /* Show in forward order * - As fac increases, the number of visible points increases */ case GP_BUILD_TRANSITION_GROW: first_visible = 0; /* always visible */ last_visible = (size_t)roundf(totpoints * fac); break; /* Hide in reverse order * - As fac increases, the number of points visible at the end decreases */ case GP_BUILD_TRANSITION_SHRINK: first_visible = 0; /* always visible (until last point removed) */ last_visible = (size_t)(totpoints * (1.0f - fac)); break; /* Hide in forward order * - As fac increases, the early points start getting hidden */ case GP_BUILD_TRANSITION_FADE: first_visible = (size_t)(totpoints * fac); last_visible = totpoints; /* i.e. visible until the end, unless first overlaps this */ break; } /* 3) Go through all strokes, deciding which to keep, and/or how much of each to keep */ for (i = 0; i < tot_strokes; i++) { tStrokeBuildDetails *cell = &table[i]; /* Determine what portion of the stroke is visible */ if ((cell->end_idx < first_visible) || (cell->start_idx > last_visible)) { /* Not visible at all - Either ended before */ clear_stroke(gpf, cell->gps); } else { /* Some proportion of stroke is visible */ /* XXX: Will the transition settings still be valid now? */ if ((first_visible <= cell->start_idx) && (last_visible >= cell->end_idx)) { /* Do nothing - whole stroke is visible */ } else if (first_visible > cell->start_idx) { /* Starts partway through this stroke */ int num_points = cell->end_idx - first_visible; reduce_stroke_points(cell->gps, num_points, mmd->transition); } else { /* Ends partway through this stroke */ int num_points = last_visible - cell->start_idx; reduce_stroke_points(cell->gps, num_points, mmd->transition); } } } /* Free table */ MEM_freeN(table); }
/* Sequential - Show strokes one after the other */
Show strokes one after the other
[ "Show", "strokes", "one", "after", "the", "other" ]
static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac) { const size_t tot_strokes = BLI_listbase_count(&gpf->strokes); bGPDstroke *gps; size_t i; tStrokeBuildDetails *table = MEM_callocN(sizeof(tStrokeBuildDetails) * tot_strokes, __func__); size_t totpoints = 0; for (gps = gpf->strokes.first, i = 0; gps; gps = gps->next, i++) { tStrokeBuildDetails *cell = &table[i]; cell->gps = gps; cell->totpoints = gps->totpoints; totpoints += cell->totpoints; } for (i = 0; i < tot_strokes; i++) { tStrokeBuildDetails *cell = &table[i]; if (i == 0) { cell->start_idx = 0; } else { cell->start_idx = (cell - 1)->end_idx; } cell->end_idx = cell->start_idx + cell->totpoints - 1; } size_t first_visible = 0; size_t last_visible = 0; switch (mmd->transition) { case GP_BUILD_TRANSITION_GROW: first_visible = 0; last_visible = (size_t)roundf(totpoints * fac); break; case GP_BUILD_TRANSITION_SHRINK: first_visible = 0; last_visible = (size_t)(totpoints * (1.0f - fac)); break; case GP_BUILD_TRANSITION_FADE: first_visible = (size_t)(totpoints * fac); last_visible = totpoints; break; } for (i = 0; i < tot_strokes; i++) { tStrokeBuildDetails *cell = &table[i]; if ((cell->end_idx < first_visible) || (cell->start_idx > last_visible)) { clear_stroke(gpf, cell->gps); } else { if ((first_visible <= cell->start_idx) && (last_visible >= cell->end_idx)) { } else if (first_visible > cell->start_idx) { int num_points = cell->end_idx - first_visible; reduce_stroke_points(cell->gps, num_points, mmd->transition); } else { int num_points = last_visible - cell->start_idx; reduce_stroke_points(cell->gps, num_points, mmd->transition); } } } MEM_freeN(table); }
[ "static", "void", "build_sequential", "(", "BuildGpencilModifierData", "*", "mmd", ",", "bGPDframe", "*", "gpf", ",", "float", "fac", ")", "{", "const", "size_t", "tot_strokes", "=", "BLI_listbase_count", "(", "&", "gpf", "->", "strokes", ")", ";", "bGPDstroke", "*", "gps", ";", "size_t", "i", ";", "tStrokeBuildDetails", "*", "table", "=", "MEM_callocN", "(", "sizeof", "(", "tStrokeBuildDetails", ")", "*", "tot_strokes", ",", "__func__", ")", ";", "size_t", "totpoints", "=", "0", ";", "for", "(", "gps", "=", "gpf", "->", "strokes", ".", "first", ",", "i", "=", "0", ";", "gps", ";", "gps", "=", "gps", "->", "next", ",", "i", "++", ")", "{", "tStrokeBuildDetails", "*", "cell", "=", "&", "table", "[", "i", "]", ";", "cell", "->", "gps", "=", "gps", ";", "cell", "->", "totpoints", "=", "gps", "->", "totpoints", ";", "totpoints", "+=", "cell", "->", "totpoints", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "tot_strokes", ";", "i", "++", ")", "{", "tStrokeBuildDetails", "*", "cell", "=", "&", "table", "[", "i", "]", ";", "if", "(", "i", "==", "0", ")", "{", "cell", "->", "start_idx", "=", "0", ";", "}", "else", "{", "cell", "->", "start_idx", "=", "(", "cell", "-", "1", ")", "->", "end_idx", ";", "}", "cell", "->", "end_idx", "=", "cell", "->", "start_idx", "+", "cell", "->", "totpoints", "-", "1", ";", "}", "size_t", "first_visible", "=", "0", ";", "size_t", "last_visible", "=", "0", ";", "switch", "(", "mmd", "->", "transition", ")", "{", "case", "GP_BUILD_TRANSITION_GROW", ":", "first_visible", "=", "0", ";", "last_visible", "=", "(", "size_t", ")", "roundf", "(", "totpoints", "*", "fac", ")", ";", "break", ";", "case", "GP_BUILD_TRANSITION_SHRINK", ":", "first_visible", "=", "0", ";", "last_visible", "=", "(", "size_t", ")", "(", "totpoints", "*", "(", "1.0f", "-", "fac", ")", ")", ";", "break", ";", "case", "GP_BUILD_TRANSITION_FADE", ":", "first_visible", "=", "(", "size_t", ")", "(", "totpoints", "*", "fac", ")", ";", "last_visible", "=", "totpoints", ";", "break", ";", "}", "for", "(", "i", "=", "0", ";", "i", "<", "tot_strokes", ";", "i", "++", ")", "{", "tStrokeBuildDetails", "*", "cell", "=", "&", "table", "[", "i", "]", ";", "if", "(", "(", "cell", "->", "end_idx", "<", "first_visible", ")", "||", "(", "cell", "->", "start_idx", ">", "last_visible", ")", ")", "{", "clear_stroke", "(", "gpf", ",", "cell", "->", "gps", ")", ";", "}", "else", "{", "if", "(", "(", "first_visible", "<=", "cell", "->", "start_idx", ")", "&&", "(", "last_visible", ">=", "cell", "->", "end_idx", ")", ")", "{", "}", "else", "if", "(", "first_visible", ">", "cell", "->", "start_idx", ")", "{", "int", "num_points", "=", "cell", "->", "end_idx", "-", "first_visible", ";", "reduce_stroke_points", "(", "cell", "->", "gps", ",", "num_points", ",", "mmd", "->", "transition", ")", ";", "}", "else", "{", "int", "num_points", "=", "last_visible", "-", "cell", "->", "start_idx", ";", "reduce_stroke_points", "(", "cell", "->", "gps", ",", "num_points", ",", "mmd", "->", "transition", ")", ";", "}", "}", "}", "MEM_freeN", "(", "table", ")", ";", "}" ]
Sequential - Show strokes one after the other
[ "Sequential", "-", "Show", "strokes", "one", "after", "the", "other" ]
[ "/* 1) Compute proportion of time each stroke should occupy */", "/* NOTE: This assumes that the total number of points won't overflow! */", "/* 1.1) First pass - Tally up points */", "/* 1.2) Second pass - Compute the overall indices for points */", "/* 2) Determine the global indices for points that should be visible */", "/* Show in forward order\n * - As fac increases, the number of visible points increases\n */", "/* always visible */", "/* Hide in reverse order\n * - As fac increases, the number of points visible at the end decreases\n */", "/* always visible (until last point removed) */", "/* Hide in forward order\n * - As fac increases, the early points start getting hidden\n */", "/* i.e. visible until the end, unless first overlaps this */", "/* 3) Go through all strokes, deciding which to keep, and/or how much of each to keep */", "/* Determine what portion of the stroke is visible */", "/* Not visible at all - Either ended before */", "/* Some proportion of stroke is visible */", "/* XXX: Will the transition settings still be valid now? */", "/* Do nothing - whole stroke is visible */", "/* Starts partway through this stroke */", "/* Ends partway through this stroke */", "/* Free table */" ]
[ { "param": "mmd", "type": "BuildGpencilModifierData" }, { "param": "gpf", "type": "bGPDframe" }, { "param": "fac", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mmd", "type": "BuildGpencilModifierData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fac", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e3e7168330d5f38c7950e8047e411e352dc4236a
DemonRem/blender
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
build_concurrent
void
static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac) { bGPDstroke *gps, *gps_next; int max_points = 0; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); /* 1) Determine the longest stroke, to figure out when short strokes should start */ /* FIXME: A *really* long stroke here could dwarf everything else, causing bad timings */ for (gps = gpf->strokes.first; gps; gps = gps->next) { if (gps->totpoints > max_points) { max_points = gps->totpoints; } } if (max_points == 0) { printf("ERROR: Strokes are all empty (GP Build Modifier: %s)\n", __func__); return; } /* 2) For each stroke, determine how it should be handled */ for (gps = gpf->strokes.first; gps; gps = gps_next) { gps_next = gps->next; /* Relative Length of Stroke - Relative to the longest stroke, * what proportion of the available time should this stroke use */ const float relative_len = (float)gps->totpoints / (float)max_points; /* Determine how many points should be left in the stroke */ int num_points = 0; switch (mmd->time_alignment) { case GP_BUILD_TIMEALIGN_START: /* all start on frame 1 */ { /* Build effect occurs over when fac = 0, to fac = relative_len */ if (fac <= relative_len) { /* Scale fac to fit relative_len */ /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */ const float scaled_fac = fac / relative_len; if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); } else { num_points = (int)roundf(scaled_fac * gps->totpoints); } } else { /* Build effect has ended */ if (reverse) { num_points = 0; } else { num_points = gps->totpoints; } } break; } case GP_BUILD_TIMEALIGN_END: /* all end on same frame */ { /* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range) */ const float start_fac = 1.0f - relative_len; if (fac >= start_fac) { /* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */ const float scaled_fac = (fac - start_fac) / relative_len; if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); } else { num_points = (int)roundf(scaled_fac * gps->totpoints); } } else { /* Build effect hasn't started */ if (reverse) { num_points = gps->totpoints; } else { num_points = 0; } } break; } /* TODO... */ } /* Modify the stroke geometry */ if (num_points <= 0) { /* Nothing Left - Delete the stroke */ clear_stroke(gpf, gps); } else if (num_points < gps->totpoints) { /* Remove some points */ reduce_stroke_points(gps, num_points, mmd->transition); } } }
/* Concurrent - Show multiple strokes at once */ // TODO: Allow random offsets to start times // TODO: Allow varying speeds? Scaling of progress?
Show multiple strokes at once TODO: Allow random offsets to start times TODO: Allow varying speeds.
[ "Show", "multiple", "strokes", "at", "once", "TODO", ":", "Allow", "random", "offsets", "to", "start", "times", "TODO", ":", "Allow", "varying", "speeds", "." ]
static void build_concurrent(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac) { bGPDstroke *gps, *gps_next; int max_points = 0; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); for (gps = gpf->strokes.first; gps; gps = gps->next) { if (gps->totpoints > max_points) { max_points = gps->totpoints; } } if (max_points == 0) { printf("ERROR: Strokes are all empty (GP Build Modifier: %s)\n", __func__); return; } for (gps = gpf->strokes.first; gps; gps = gps_next) { gps_next = gps->next; const float relative_len = (float)gps->totpoints / (float)max_points; int num_points = 0; switch (mmd->time_alignment) { case GP_BUILD_TIMEALIGN_START: { if (fac <= relative_len) { const float scaled_fac = fac / relative_len; if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); } else { num_points = (int)roundf(scaled_fac * gps->totpoints); } } else { if (reverse) { num_points = 0; } else { num_points = gps->totpoints; } } break; } case GP_BUILD_TIMEALIGN_END: { const float start_fac = 1.0f - relative_len; if (fac >= start_fac) { const float scaled_fac = (fac - start_fac) / relative_len; if (reverse) { num_points = (int)roundf((1.0f - scaled_fac) * gps->totpoints); } else { num_points = (int)roundf(scaled_fac * gps->totpoints); } } else { if (reverse) { num_points = gps->totpoints; } else { num_points = 0; } } break; } } if (num_points <= 0) { clear_stroke(gpf, gps); } else if (num_points < gps->totpoints) { reduce_stroke_points(gps, num_points, mmd->transition); } } }
[ "static", "void", "build_concurrent", "(", "BuildGpencilModifierData", "*", "mmd", ",", "bGPDframe", "*", "gpf", ",", "float", "fac", ")", "{", "bGPDstroke", "*", "gps", ",", "*", "gps_next", ";", "int", "max_points", "=", "0", ";", "const", "bool", "reverse", "=", "(", "mmd", "->", "transition", "!=", "GP_BUILD_TRANSITION_GROW", ")", ";", "for", "(", "gps", "=", "gpf", "->", "strokes", ".", "first", ";", "gps", ";", "gps", "=", "gps", "->", "next", ")", "{", "if", "(", "gps", "->", "totpoints", ">", "max_points", ")", "{", "max_points", "=", "gps", "->", "totpoints", ";", "}", "}", "if", "(", "max_points", "==", "0", ")", "{", "printf", "(", "\"", "\\n", "\"", ",", "__func__", ")", ";", "return", ";", "}", "for", "(", "gps", "=", "gpf", "->", "strokes", ".", "first", ";", "gps", ";", "gps", "=", "gps_next", ")", "{", "gps_next", "=", "gps", "->", "next", ";", "const", "float", "relative_len", "=", "(", "float", ")", "gps", "->", "totpoints", "/", "(", "float", ")", "max_points", ";", "int", "num_points", "=", "0", ";", "switch", "(", "mmd", "->", "time_alignment", ")", "{", "case", "GP_BUILD_TIMEALIGN_START", ":", "{", "if", "(", "fac", "<=", "relative_len", ")", "{", "const", "float", "scaled_fac", "=", "fac", "/", "relative_len", ";", "if", "(", "reverse", ")", "{", "num_points", "=", "(", "int", ")", "roundf", "(", "(", "1.0f", "-", "scaled_fac", ")", "*", "gps", "->", "totpoints", ")", ";", "}", "else", "{", "num_points", "=", "(", "int", ")", "roundf", "(", "scaled_fac", "*", "gps", "->", "totpoints", ")", ";", "}", "}", "else", "{", "if", "(", "reverse", ")", "{", "num_points", "=", "0", ";", "}", "else", "{", "num_points", "=", "gps", "->", "totpoints", ";", "}", "}", "break", ";", "}", "case", "GP_BUILD_TIMEALIGN_END", ":", "{", "const", "float", "start_fac", "=", "1.0f", "-", "relative_len", ";", "if", "(", "fac", ">=", "start_fac", ")", "{", "const", "float", "scaled_fac", "=", "(", "fac", "-", "start_fac", ")", "/", "relative_len", ";", "if", "(", "reverse", ")", "{", "num_points", "=", "(", "int", ")", "roundf", "(", "(", "1.0f", "-", "scaled_fac", ")", "*", "gps", "->", "totpoints", ")", ";", "}", "else", "{", "num_points", "=", "(", "int", ")", "roundf", "(", "scaled_fac", "*", "gps", "->", "totpoints", ")", ";", "}", "}", "else", "{", "if", "(", "reverse", ")", "{", "num_points", "=", "gps", "->", "totpoints", ";", "}", "else", "{", "num_points", "=", "0", ";", "}", "}", "break", ";", "}", "}", "if", "(", "num_points", "<=", "0", ")", "{", "clear_stroke", "(", "gpf", ",", "gps", ")", ";", "}", "else", "if", "(", "num_points", "<", "gps", "->", "totpoints", ")", "{", "reduce_stroke_points", "(", "gps", ",", "num_points", ",", "mmd", "->", "transition", ")", ";", "}", "}", "}" ]
Concurrent - Show multiple strokes at once TODO: Allow random offsets to start times TODO: Allow varying speeds?
[ "Concurrent", "-", "Show", "multiple", "strokes", "at", "once", "TODO", ":", "Allow", "random", "offsets", "to", "start", "times", "TODO", ":", "Allow", "varying", "speeds?" ]
[ "/* 1) Determine the longest stroke, to figure out when short strokes should start */", "/* FIXME: A *really* long stroke here could dwarf everything else, causing bad timings */", "/* 2) For each stroke, determine how it should be handled */", "/* Relative Length of Stroke - Relative to the longest stroke,\n * what proportion of the available time should this stroke use\n */", "/* Determine how many points should be left in the stroke */", "/* all start on frame 1 */", "/* Build effect occurs over when fac = 0, to fac = relative_len */", "/* Scale fac to fit relative_len */", "/* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */", "/* Build effect has ended */", "/* all end on same frame */", "/* Build effect occurs over 1.0 - relative_len, to 1.0 (i.e. over the end of the range)\n */", "/* FIXME: prevent potential div by zero (e.g. very short stroke vs one very long one) */", "/* Build effect hasn't started */", "/* TODO... */", "/* Modify the stroke geometry */", "/* Nothing Left - Delete the stroke */", "/* Remove some points */" ]
[ { "param": "mmd", "type": "BuildGpencilModifierData" }, { "param": "gpf", "type": "bGPDframe" }, { "param": "fac", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mmd", "type": "BuildGpencilModifierData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "fac", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e3e7168330d5f38c7950e8047e411e352dc4236a
DemonRem/blender
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
generateStrokes
void
static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Object *UNUSED(ob), bGPDlayer *gpl, bGPDframe *gpf) { BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); const float ctime = DEG_get_ctime(depsgraph); // printf("GP Build Modifier - %f\n", ctime); /* Early exit if it's an empty frame */ if (gpf->strokes.first == NULL) { return; } /* Omit layer if filter by layer */ if (mmd->layername[0] != '\0') { if ((mmd->flag & GP_BUILD_INVERT_LAYER) == 0) { if (!STREQ(mmd->layername, gpl->info)) { return; } } else { if (STREQ(mmd->layername, gpl->info)) { return; } } } /* verify layer pass */ if (mmd->layer_pass > 0) { if ((mmd->flag & GP_BUILD_INVERT_LAYERPASS) == 0) { if (gpl->pass_index != mmd->layer_pass) { return; } } else { if (gpl->pass_index == mmd->layer_pass) { return; } } } /* Early exit if outside of the frame range for this modifier * (e.g. to have one forward, and one backwards modifier) */ if (mmd->flag & GP_BUILD_RESTRICT_TIME) { if ((ctime < mmd->start_frame) || (ctime > mmd->end_frame)) { return; } } /* Compute start and end frames for the animation effect * By default, the upper bound is given by the "maximum length" setting */ float start_frame = gpf->framenum + mmd->start_delay; float end_frame = gpf->framenum + mmd->length; if (gpf->next) { /* Use the next frame or upper bound as end frame, whichever is lower/closer */ end_frame = MIN2(end_frame, gpf->next->framenum); } /* Early exit if current frame is outside start/end bounds */ /* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem * anyway... */ if (ctime < start_frame) { /* Before Start - Animation hasn't started. Display initial state. */ if (reverse) { /* 1) Reverse = Start with all, end with nothing. * ==> Do nothing (everything already present) */ } else { /* 2) Forward Order = Start with nothing, end with the full frame. * ==> Free all strokes, and return an empty frame */ gpf_clear_all_strokes(gpf); } /* Early exit */ return; } else if (ctime >= end_frame) { /* Past End - Animation finished. Display final result. */ if (reverse) { /* 1) Reverse = Start with all, end with nothing. * ==> Free all strokes, and return an empty frame */ gpf_clear_all_strokes(gpf); } else { /* 2) Forward Order = Start with nothing, end with the full frame. * ==> Do Nothing (everything already present) */ } /* Early exit */ return; } /* Determine how far along we are between the keyframes */ float fac = (ctime - start_frame) / (end_frame - start_frame); // printf(" Progress on %d = %f (%f - %f)\n", gpf->framenum, fac, start_frame, end_frame); /* Time management mode */ switch (mmd->mode) { case GP_BUILD_MODE_SEQUENTIAL: build_sequential(mmd, gpf, fac); break; case GP_BUILD_MODE_CONCURRENT: build_concurrent(mmd, gpf, fac); break; default: printf("Unsupported build mode (%d) for GP Build Modifier: '%s'\n", mmd->mode, mmd->modifier.name); break; } }
/* Entry-point for Build Modifier */
Entry-point for Build Modifier
[ "Entry", "-", "point", "for", "Build", "Modifier" ]
static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Object *UNUSED(ob), bGPDlayer *gpl, bGPDframe *gpf) { BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); const float ctime = DEG_get_ctime(depsgraph); if (gpf->strokes.first == NULL) { return; } if (mmd->layername[0] != '\0') { if ((mmd->flag & GP_BUILD_INVERT_LAYER) == 0) { if (!STREQ(mmd->layername, gpl->info)) { return; } } else { if (STREQ(mmd->layername, gpl->info)) { return; } } } if (mmd->layer_pass > 0) { if ((mmd->flag & GP_BUILD_INVERT_LAYERPASS) == 0) { if (gpl->pass_index != mmd->layer_pass) { return; } } else { if (gpl->pass_index == mmd->layer_pass) { return; } } } if (mmd->flag & GP_BUILD_RESTRICT_TIME) { if ((ctime < mmd->start_frame) || (ctime > mmd->end_frame)) { return; } } float start_frame = gpf->framenum + mmd->start_delay; float end_frame = gpf->framenum + mmd->length; if (gpf->next) { end_frame = MIN2(end_frame, gpf->next->framenum); } if (ctime < start_frame) { if (reverse) { } else { gpf_clear_all_strokes(gpf); } return; } else if (ctime >= end_frame) { if (reverse) { gpf_clear_all_strokes(gpf); } else { } return; } float fac = (ctime - start_frame) / (end_frame - start_frame); switch (mmd->mode) { case GP_BUILD_MODE_SEQUENTIAL: build_sequential(mmd, gpf, fac); break; case GP_BUILD_MODE_CONCURRENT: build_concurrent(mmd, gpf, fac); break; default: printf("Unsupported build mode (%d) for GP Build Modifier: '%s'\n", mmd->mode, mmd->modifier.name); break; } }
[ "static", "void", "generateStrokes", "(", "GpencilModifierData", "*", "md", ",", "Depsgraph", "*", "depsgraph", ",", "Object", "*", "UNUSED", "(", "ob", ")", ",", "bGPDlayer", "*", "gpl", ",", "bGPDframe", "*", "gpf", ")", "{", "BuildGpencilModifierData", "*", "mmd", "=", "(", "BuildGpencilModifierData", "*", ")", "md", ";", "const", "bool", "reverse", "=", "(", "mmd", "->", "transition", "!=", "GP_BUILD_TRANSITION_GROW", ")", ";", "const", "float", "ctime", "=", "DEG_get_ctime", "(", "depsgraph", ")", ";", "if", "(", "gpf", "->", "strokes", ".", "first", "==", "NULL", ")", "{", "return", ";", "}", "if", "(", "mmd", "->", "layername", "[", "0", "]", "!=", "'", "\\0", "'", ")", "{", "if", "(", "(", "mmd", "->", "flag", "&", "GP_BUILD_INVERT_LAYER", ")", "==", "0", ")", "{", "if", "(", "!", "STREQ", "(", "mmd", "->", "layername", ",", "gpl", "->", "info", ")", ")", "{", "return", ";", "}", "}", "else", "{", "if", "(", "STREQ", "(", "mmd", "->", "layername", ",", "gpl", "->", "info", ")", ")", "{", "return", ";", "}", "}", "}", "if", "(", "mmd", "->", "layer_pass", ">", "0", ")", "{", "if", "(", "(", "mmd", "->", "flag", "&", "GP_BUILD_INVERT_LAYERPASS", ")", "==", "0", ")", "{", "if", "(", "gpl", "->", "pass_index", "!=", "mmd", "->", "layer_pass", ")", "{", "return", ";", "}", "}", "else", "{", "if", "(", "gpl", "->", "pass_index", "==", "mmd", "->", "layer_pass", ")", "{", "return", ";", "}", "}", "}", "if", "(", "mmd", "->", "flag", "&", "GP_BUILD_RESTRICT_TIME", ")", "{", "if", "(", "(", "ctime", "<", "mmd", "->", "start_frame", ")", "||", "(", "ctime", ">", "mmd", "->", "end_frame", ")", ")", "{", "return", ";", "}", "}", "float", "start_frame", "=", "gpf", "->", "framenum", "+", "mmd", "->", "start_delay", ";", "float", "end_frame", "=", "gpf", "->", "framenum", "+", "mmd", "->", "length", ";", "if", "(", "gpf", "->", "next", ")", "{", "end_frame", "=", "MIN2", "(", "end_frame", ",", "gpf", "->", "next", "->", "framenum", ")", ";", "}", "if", "(", "ctime", "<", "start_frame", ")", "{", "if", "(", "reverse", ")", "{", "}", "else", "{", "gpf_clear_all_strokes", "(", "gpf", ")", ";", "}", "return", ";", "}", "else", "if", "(", "ctime", ">=", "end_frame", ")", "{", "if", "(", "reverse", ")", "{", "gpf_clear_all_strokes", "(", "gpf", ")", ";", "}", "else", "{", "}", "return", ";", "}", "float", "fac", "=", "(", "ctime", "-", "start_frame", ")", "/", "(", "end_frame", "-", "start_frame", ")", ";", "switch", "(", "mmd", "->", "mode", ")", "{", "case", "GP_BUILD_MODE_SEQUENTIAL", ":", "build_sequential", "(", "mmd", ",", "gpf", ",", "fac", ")", ";", "break", ";", "case", "GP_BUILD_MODE_CONCURRENT", ":", "build_concurrent", "(", "mmd", ",", "gpf", ",", "fac", ")", ";", "break", ";", "default", ":", "printf", "(", "\"", "\\n", "\"", ",", "mmd", "->", "mode", ",", "mmd", "->", "modifier", ".", "name", ")", ";", "break", ";", "}", "}" ]
Entry-point for Build Modifier
[ "Entry", "-", "point", "for", "Build", "Modifier" ]
[ "// printf(\"GP Build Modifier - %f\\n\", ctime);", "/* Early exit if it's an empty frame */", "/* Omit layer if filter by layer */", "/* verify layer pass */", "/* Early exit if outside of the frame range for this modifier\n * (e.g. to have one forward, and one backwards modifier)\n */", "/* Compute start and end frames for the animation effect\n * By default, the upper bound is given by the \"maximum length\" setting\n */", "/* Use the next frame or upper bound as end frame, whichever is lower/closer */", "/* Early exit if current frame is outside start/end bounds */", "/* NOTE: If we're beyond the next/prev frames (if existent), then we wouldn't have this problem\n * anyway... */", "/* Before Start - Animation hasn't started. Display initial state. */", "/* 1) Reverse = Start with all, end with nothing.\n * ==> Do nothing (everything already present)\n */", "/* 2) Forward Order = Start with nothing, end with the full frame.\n * ==> Free all strokes, and return an empty frame\n */", "/* Early exit */", "/* Past End - Animation finished. Display final result. */", "/* 1) Reverse = Start with all, end with nothing.\n * ==> Free all strokes, and return an empty frame\n */", "/* 2) Forward Order = Start with nothing, end with the full frame.\n * ==> Do Nothing (everything already present)\n */", "/* Early exit */", "/* Determine how far along we are between the keyframes */", "// printf(\" Progress on %d = %f (%f - %f)\\n\", gpf->framenum, fac, start_frame, end_frame);", "/* Time management mode */" ]
[ { "param": "md", "type": "GpencilModifierData" }, { "param": "depsgraph", "type": "Depsgraph" }, { "param": "UNUSED", "type": "Object" }, { "param": "gpl", "type": "bGPDlayer" }, { "param": "gpf", "type": "bGPDframe" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "md", "type": "GpencilModifierData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "depsgraph", "type": "Depsgraph", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "UNUSED", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpl", "type": "bGPDlayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ca3da0d89c7a483c885bf15953fa900a899bc162
DemonRem/blender
source/blender/blenkernel/intern/library_query.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_library_foreach_ID_link
void
void BKE_library_foreach_ID_link( Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag) { library_foreach_ID_link(bmain, id, callback, user_data, flag, NULL); }
/** * Loop over all of the ID's this data-block links to. */
Loop over all of the ID's this data-block links to.
[ "Loop", "over", "all", "of", "the", "ID", "'", "s", "this", "data", "-", "block", "links", "to", "." ]
void BKE_library_foreach_ID_link( Main *bmain, ID *id, LibraryIDLinkCallback callback, void *user_data, int flag) { library_foreach_ID_link(bmain, id, callback, user_data, flag, NULL); }
[ "void", "BKE_library_foreach_ID_link", "(", "Main", "*", "bmain", ",", "ID", "*", "id", ",", "LibraryIDLinkCallback", "callback", ",", "void", "*", "user_data", ",", "int", "flag", ")", "{", "library_foreach_ID_link", "(", "bmain", ",", "id", ",", "callback", ",", "user_data", ",", "flag", ",", "NULL", ")", ";", "}" ]
Loop over all of the ID's this data-block links to.
[ "Loop", "over", "all", "of", "the", "ID", "'", "s", "this", "data", "-", "block", "links", "to", "." ]
[]
[ { "param": "bmain", "type": "Main" }, { "param": "id", "type": "ID" }, { "param": "callback", "type": "LibraryIDLinkCallback" }, { "param": "user_data", "type": "void" }, { "param": "flag", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id", "type": "ID", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "callback", "type": "LibraryIDLinkCallback", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_data", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flag", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ca3da0d89c7a483c885bf15953fa900a899bc162
DemonRem/blender
source/blender/blenkernel/intern/library_query.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_library_id_can_use_idtype
bool
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) { /* any type of ID can be used in custom props. */ if (id_owner->properties) { return true; } const short id_type_owner = GS(id_owner->name); /* IDProps of armature bones and nodes, and bNode->id can use virtually any type of ID. */ if (ELEM(id_type_owner, ID_NT, ID_AR)) { return true; } if (ntreeFromID(id_owner)) { return true; } if (BKE_animdata_from_id(id_owner)) { /* AnimationData can use virtually any kind of data-blocks, through drivers especially. */ return true; } switch ((ID_Type)id_type_owner) { case ID_LI: return ELEM(id_type_used, ID_LI); case ID_SCE: return (ELEM(id_type_used, ID_OB, ID_WO, ID_SCE, ID_MC, ID_MA, ID_GR, ID_TXT, ID_LS, ID_MSK, ID_SO, ID_GD, ID_BR, ID_PAL, ID_IM, ID_NT)); case ID_OB: /* Could be more specific, but simpler to just always say 'yes' here. */ return true; case ID_ME: return ELEM(id_type_used, ID_ME, ID_KE, ID_MA, ID_IM); case ID_CU: return ELEM(id_type_used, ID_OB, ID_KE, ID_MA, ID_VF); case ID_MB: return ELEM(id_type_used, ID_MA); case ID_MA: return (ELEM(id_type_used, ID_TE, ID_GR)); case ID_TE: return (ELEM(id_type_used, ID_IM, ID_OB)); case ID_LT: return ELEM(id_type_used, ID_KE); case ID_LA: return (ELEM(id_type_used, ID_TE)); case ID_CA: return ELEM(id_type_used, ID_OB); case ID_KE: /* Warning! key->from, could be more types in future? */ return ELEM(id_type_used, ID_ME, ID_CU, ID_LT); case ID_SCR: return ELEM(id_type_used, ID_SCE); case ID_WO: return (ELEM(id_type_used, ID_TE)); case ID_SPK: return ELEM(id_type_used, ID_SO); case ID_GR: return ELEM(id_type_used, ID_OB, ID_GR); case ID_NT: /* Could be more specific, but node.id has no type restriction... */ return true; case ID_BR: return ELEM(id_type_used, ID_BR, ID_IM, ID_PC, ID_TE, ID_MA); case ID_PA: return ELEM(id_type_used, ID_OB, ID_GR, ID_TE); case ID_MC: return ELEM(id_type_used, ID_GD, ID_IM); case ID_MSK: /* WARNING! mask->parent.id, not typed. */ return ELEM(id_type_used, ID_MC); case ID_LS: return (ELEM(id_type_used, ID_TE, ID_OB)); case ID_LP: return ELEM(id_type_used, ID_IM); case ID_GD: return ELEM(id_type_used, ID_MA); case ID_WS: return ELEM(id_type_used, ID_SCR, ID_SCE); case ID_IM: case ID_VF: case ID_TXT: case ID_SO: case ID_AR: case ID_AC: case ID_WM: case ID_PAL: case ID_PC: case ID_CF: /* Those types never use/reference other IDs... */ return false; case ID_IP: /* Deprecated... */ return false; } return false; }
/* XXX This has to be fully rethink, basing check on ID type is not really working anymore * (and even worth once IDProps will support ID pointers), * we'll have to do some quick checks on IDs themselves... */
XXX This has to be fully rethink, basing check on ID type is not really working anymore (and even worth once IDProps will support ID pointers), we'll have to do some quick checks on IDs themselves
[ "XXX", "This", "has", "to", "be", "fully", "rethink", "basing", "check", "on", "ID", "type", "is", "not", "really", "working", "anymore", "(", "and", "even", "worth", "once", "IDProps", "will", "support", "ID", "pointers", ")", "we", "'", "ll", "have", "to", "do", "some", "quick", "checks", "on", "IDs", "themselves" ]
bool BKE_library_id_can_use_idtype(ID *id_owner, const short id_type_used) { if (id_owner->properties) { return true; } const short id_type_owner = GS(id_owner->name); if (ELEM(id_type_owner, ID_NT, ID_AR)) { return true; } if (ntreeFromID(id_owner)) { return true; } if (BKE_animdata_from_id(id_owner)) { return true; } switch ((ID_Type)id_type_owner) { case ID_LI: return ELEM(id_type_used, ID_LI); case ID_SCE: return (ELEM(id_type_used, ID_OB, ID_WO, ID_SCE, ID_MC, ID_MA, ID_GR, ID_TXT, ID_LS, ID_MSK, ID_SO, ID_GD, ID_BR, ID_PAL, ID_IM, ID_NT)); case ID_OB: return true; case ID_ME: return ELEM(id_type_used, ID_ME, ID_KE, ID_MA, ID_IM); case ID_CU: return ELEM(id_type_used, ID_OB, ID_KE, ID_MA, ID_VF); case ID_MB: return ELEM(id_type_used, ID_MA); case ID_MA: return (ELEM(id_type_used, ID_TE, ID_GR)); case ID_TE: return (ELEM(id_type_used, ID_IM, ID_OB)); case ID_LT: return ELEM(id_type_used, ID_KE); case ID_LA: return (ELEM(id_type_used, ID_TE)); case ID_CA: return ELEM(id_type_used, ID_OB); case ID_KE: return ELEM(id_type_used, ID_ME, ID_CU, ID_LT); case ID_SCR: return ELEM(id_type_used, ID_SCE); case ID_WO: return (ELEM(id_type_used, ID_TE)); case ID_SPK: return ELEM(id_type_used, ID_SO); case ID_GR: return ELEM(id_type_used, ID_OB, ID_GR); case ID_NT: return true; case ID_BR: return ELEM(id_type_used, ID_BR, ID_IM, ID_PC, ID_TE, ID_MA); case ID_PA: return ELEM(id_type_used, ID_OB, ID_GR, ID_TE); case ID_MC: return ELEM(id_type_used, ID_GD, ID_IM); case ID_MSK: return ELEM(id_type_used, ID_MC); case ID_LS: return (ELEM(id_type_used, ID_TE, ID_OB)); case ID_LP: return ELEM(id_type_used, ID_IM); case ID_GD: return ELEM(id_type_used, ID_MA); case ID_WS: return ELEM(id_type_used, ID_SCR, ID_SCE); case ID_IM: case ID_VF: case ID_TXT: case ID_SO: case ID_AR: case ID_AC: case ID_WM: case ID_PAL: case ID_PC: case ID_CF: return false; case ID_IP: return false; } return false; }
[ "bool", "BKE_library_id_can_use_idtype", "(", "ID", "*", "id_owner", ",", "const", "short", "id_type_used", ")", "{", "if", "(", "id_owner", "->", "properties", ")", "{", "return", "true", ";", "}", "const", "short", "id_type_owner", "=", "GS", "(", "id_owner", "->", "name", ")", ";", "if", "(", "ELEM", "(", "id_type_owner", ",", "ID_NT", ",", "ID_AR", ")", ")", "{", "return", "true", ";", "}", "if", "(", "ntreeFromID", "(", "id_owner", ")", ")", "{", "return", "true", ";", "}", "if", "(", "BKE_animdata_from_id", "(", "id_owner", ")", ")", "{", "return", "true", ";", "}", "switch", "(", "(", "ID_Type", ")", "id_type_owner", ")", "{", "case", "ID_LI", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_LI", ")", ";", "case", "ID_SCE", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_OB", ",", "ID_WO", ",", "ID_SCE", ",", "ID_MC", ",", "ID_MA", ",", "ID_GR", ",", "ID_TXT", ",", "ID_LS", ",", "ID_MSK", ",", "ID_SO", ",", "ID_GD", ",", "ID_BR", ",", "ID_PAL", ",", "ID_IM", ",", "ID_NT", ")", ")", ";", "case", "ID_OB", ":", "return", "true", ";", "case", "ID_ME", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_ME", ",", "ID_KE", ",", "ID_MA", ",", "ID_IM", ")", ";", "case", "ID_CU", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_OB", ",", "ID_KE", ",", "ID_MA", ",", "ID_VF", ")", ";", "case", "ID_MB", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_MA", ")", ";", "case", "ID_MA", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_TE", ",", "ID_GR", ")", ")", ";", "case", "ID_TE", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_IM", ",", "ID_OB", ")", ")", ";", "case", "ID_LT", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_KE", ")", ";", "case", "ID_LA", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_TE", ")", ")", ";", "case", "ID_CA", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_OB", ")", ";", "case", "ID_KE", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_ME", ",", "ID_CU", ",", "ID_LT", ")", ";", "case", "ID_SCR", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_SCE", ")", ";", "case", "ID_WO", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_TE", ")", ")", ";", "case", "ID_SPK", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_SO", ")", ";", "case", "ID_GR", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_OB", ",", "ID_GR", ")", ";", "case", "ID_NT", ":", "return", "true", ";", "case", "ID_BR", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_BR", ",", "ID_IM", ",", "ID_PC", ",", "ID_TE", ",", "ID_MA", ")", ";", "case", "ID_PA", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_OB", ",", "ID_GR", ",", "ID_TE", ")", ";", "case", "ID_MC", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_GD", ",", "ID_IM", ")", ";", "case", "ID_MSK", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_MC", ")", ";", "case", "ID_LS", ":", "return", "(", "ELEM", "(", "id_type_used", ",", "ID_TE", ",", "ID_OB", ")", ")", ";", "case", "ID_LP", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_IM", ")", ";", "case", "ID_GD", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_MA", ")", ";", "case", "ID_WS", ":", "return", "ELEM", "(", "id_type_used", ",", "ID_SCR", ",", "ID_SCE", ")", ";", "case", "ID_IM", ":", "case", "ID_VF", ":", "case", "ID_TXT", ":", "case", "ID_SO", ":", "case", "ID_AR", ":", "case", "ID_AC", ":", "case", "ID_WM", ":", "case", "ID_PAL", ":", "case", "ID_PC", ":", "case", "ID_CF", ":", "return", "false", ";", "case", "ID_IP", ":", "return", "false", ";", "}", "return", "false", ";", "}" ]
XXX This has to be fully rethink, basing check on ID type is not really working anymore (and even worth once IDProps will support ID pointers), we'll have to do some quick checks on IDs themselves...
[ "XXX", "This", "has", "to", "be", "fully", "rethink", "basing", "check", "on", "ID", "type", "is", "not", "really", "working", "anymore", "(", "and", "even", "worth", "once", "IDProps", "will", "support", "ID", "pointers", ")", "we", "'", "ll", "have", "to", "do", "some", "quick", "checks", "on", "IDs", "themselves", "..." ]
[ "/* any type of ID can be used in custom props. */", "/* IDProps of armature bones and nodes, and bNode->id can use virtually any type of ID. */", "/* AnimationData can use virtually any kind of data-blocks, through drivers especially. */", "/* Could be more specific, but simpler to just always say 'yes' here. */", "/* Warning! key->from, could be more types in future? */", "/* Could be more specific, but node.id has no type restriction... */", "/* WARNING! mask->parent.id, not typed. */", "/* Those types never use/reference other IDs... */", "/* Deprecated... */" ]
[ { "param": "id_owner", "type": "ID" }, { "param": "id_type_used", "type": "short" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "id_owner", "type": "ID", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "id_type_used", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ca3da0d89c7a483c885bf15953fa900a899bc162
DemonRem/blender
source/blender/blenkernel/intern/library_query.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
BKE_library_indirectly_used_data_tag_clear
void
void BKE_library_indirectly_used_data_tag_clear(Main *bmain) { ListBase *lb_array[MAX_LIBARRAY]; bool do_loop = true; while (do_loop) { int i = set_listbasepointers(bmain, lb_array); do_loop = false; while (i--) { for (ID *id = lb_array[i]->first; id; id = id->next) { if (id->lib == NULL || id->tag & LIB_TAG_DOIT) { /* Local or non-indirectly-used ID (so far), no need to check it further. */ continue; } BKE_library_foreach_ID_link( bmain, id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_READONLY); } } } }
/** * Untag linked data blocks used by other untagged linked data-blocks. * Used to detect data-blocks that we can forcefully make local * (instead of copying them to later get rid of original): * All data-blocks we want to make local are tagged by caller, * after this function has ran caller knows data-blocks still tagged can directly be made local, * since they are only used by other data-blocks that will also be made fully local. */
Untag linked data blocks used by other untagged linked data-blocks. Used to detect data-blocks that we can forcefully make local (instead of copying them to later get rid of original): All data-blocks we want to make local are tagged by caller, after this function has ran caller knows data-blocks still tagged can directly be made local, since they are only used by other data-blocks that will also be made fully local.
[ "Untag", "linked", "data", "blocks", "used", "by", "other", "untagged", "linked", "data", "-", "blocks", ".", "Used", "to", "detect", "data", "-", "blocks", "that", "we", "can", "forcefully", "make", "local", "(", "instead", "of", "copying", "them", "to", "later", "get", "rid", "of", "original", ")", ":", "All", "data", "-", "blocks", "we", "want", "to", "make", "local", "are", "tagged", "by", "caller", "after", "this", "function", "has", "ran", "caller", "knows", "data", "-", "blocks", "still", "tagged", "can", "directly", "be", "made", "local", "since", "they", "are", "only", "used", "by", "other", "data", "-", "blocks", "that", "will", "also", "be", "made", "fully", "local", "." ]
void BKE_library_indirectly_used_data_tag_clear(Main *bmain) { ListBase *lb_array[MAX_LIBARRAY]; bool do_loop = true; while (do_loop) { int i = set_listbasepointers(bmain, lb_array); do_loop = false; while (i--) { for (ID *id = lb_array[i]->first; id; id = id->next) { if (id->lib == NULL || id->tag & LIB_TAG_DOIT) { continue; } BKE_library_foreach_ID_link( bmain, id, foreach_libblock_used_linked_data_tag_clear_cb, &do_loop, IDWALK_READONLY); } } } }
[ "void", "BKE_library_indirectly_used_data_tag_clear", "(", "Main", "*", "bmain", ")", "{", "ListBase", "*", "lb_array", "[", "MAX_LIBARRAY", "]", ";", "bool", "do_loop", "=", "true", ";", "while", "(", "do_loop", ")", "{", "int", "i", "=", "set_listbasepointers", "(", "bmain", ",", "lb_array", ")", ";", "do_loop", "=", "false", ";", "while", "(", "i", "--", ")", "{", "for", "(", "ID", "*", "id", "=", "lb_array", "[", "i", "]", "->", "first", ";", "id", ";", "id", "=", "id", "->", "next", ")", "{", "if", "(", "id", "->", "lib", "==", "NULL", "||", "id", "->", "tag", "&", "LIB_TAG_DOIT", ")", "{", "continue", ";", "}", "BKE_library_foreach_ID_link", "(", "bmain", ",", "id", ",", "foreach_libblock_used_linked_data_tag_clear_cb", ",", "&", "do_loop", ",", "IDWALK_READONLY", ")", ";", "}", "}", "}", "}" ]
Untag linked data blocks used by other untagged linked data-blocks.
[ "Untag", "linked", "data", "blocks", "used", "by", "other", "untagged", "linked", "data", "-", "blocks", "." ]
[ "/* Local or non-indirectly-used ID (so far), no need to check it further. */" ]
[ { "param": "bmain", "type": "Main" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46dcc6c6f781612ce47b9bbf1de1274718c58542
DemonRem/blender
source/blender/gpu/intern/gpu_uniformbuffer.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
GPU_uniformbuffer_dynamic_create
GPUUniformBuffer
GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256]) { /* There is no point on creating an UBO if there is no arguments. */ if (BLI_listbase_is_empty(inputs)) { return NULL; } GPUUniformBufferDynamic *ubo = MEM_callocN(sizeof(GPUUniformBufferDynamic), "GPUUniformBufferDynamic"); ubo->buffer.type = GPU_UBO_DYNAMIC; ubo->buffer.bindpoint = -1; ubo->flag = GPU_UBO_FLAG_DIRTY; /* Generate Buffer object. */ ubo->buffer.bindcode = GPU_buf_alloc(); if (!ubo->buffer.bindcode) { if (err_out) { BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256); } GPU_uniformbuffer_free(&ubo->buffer); return NULL; } if (ubo->buffer.size > GPU_max_ubo_size()) { if (err_out) { BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256); } GPU_uniformbuffer_free(&ubo->buffer); return NULL; } /* Make sure we comply to the ubo alignment requirements. */ gpu_uniformbuffer_inputs_sort(inputs); for (LinkData *link = inputs->first; link; link = link->next) { const eGPUType gputype = get_padded_gpu_type(link); ubo->buffer.size += gputype * sizeof(float); } /* Round up to size of vec4 */ ubo->buffer.size = ((ubo->buffer.size + 15) / 16) * 16; /* Allocate the data. */ ubo->data = MEM_mallocN(ubo->buffer.size, __func__); /* Now that we know the total ubo size we can start populating it. */ float *offset = ubo->data; for (LinkData *link = inputs->first; link; link = link->next) { GPUInput *input = link->data; memcpy(offset, input->vec, input->type * sizeof(float)); offset += get_padded_gpu_type(link); } /* Note since we may create the UBOs in the CPU in a different thread than the main drawing one, * we don't create the UBO in the GPU here. This will happen when we first bind the UBO. */ return &ubo->buffer; }
/** * Create dynamic UBO from parameters * Return NULL if failed to create or if \param inputs: is empty. * * \param inputs: ListBase of #BLI_genericNodeN(#GPUInput). */
Create dynamic UBO from parameters Return NULL if failed to create or if \param inputs: is empty.
[ "Create", "dynamic", "UBO", "from", "parameters", "Return", "NULL", "if", "failed", "to", "create", "or", "if", "\\", "param", "inputs", ":", "is", "empty", "." ]
GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256]) { if (BLI_listbase_is_empty(inputs)) { return NULL; } GPUUniformBufferDynamic *ubo = MEM_callocN(sizeof(GPUUniformBufferDynamic), "GPUUniformBufferDynamic"); ubo->buffer.type = GPU_UBO_DYNAMIC; ubo->buffer.bindpoint = -1; ubo->flag = GPU_UBO_FLAG_DIRTY; ubo->buffer.bindcode = GPU_buf_alloc(); if (!ubo->buffer.bindcode) { if (err_out) { BLI_strncpy(err_out, "GPUUniformBuffer: UBO create failed", 256); } GPU_uniformbuffer_free(&ubo->buffer); return NULL; } if (ubo->buffer.size > GPU_max_ubo_size()) { if (err_out) { BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256); } GPU_uniformbuffer_free(&ubo->buffer); return NULL; } gpu_uniformbuffer_inputs_sort(inputs); for (LinkData *link = inputs->first; link; link = link->next) { const eGPUType gputype = get_padded_gpu_type(link); ubo->buffer.size += gputype * sizeof(float); } ubo->buffer.size = ((ubo->buffer.size + 15) / 16) * 16; ubo->data = MEM_mallocN(ubo->buffer.size, __func__); float *offset = ubo->data; for (LinkData *link = inputs->first; link; link = link->next) { GPUInput *input = link->data; memcpy(offset, input->vec, input->type * sizeof(float)); offset += get_padded_gpu_type(link); } return &ubo->buffer; }
[ "GPUUniformBuffer", "*", "GPU_uniformbuffer_dynamic_create", "(", "ListBase", "*", "inputs", ",", "char", "err_out", "[", "256", "]", ")", "{", "if", "(", "BLI_listbase_is_empty", "(", "inputs", ")", ")", "{", "return", "NULL", ";", "}", "GPUUniformBufferDynamic", "*", "ubo", "=", "MEM_callocN", "(", "sizeof", "(", "GPUUniformBufferDynamic", ")", ",", "\"", "\"", ")", ";", "ubo", "->", "buffer", ".", "type", "=", "GPU_UBO_DYNAMIC", ";", "ubo", "->", "buffer", ".", "bindpoint", "=", "-1", ";", "ubo", "->", "flag", "=", "GPU_UBO_FLAG_DIRTY", ";", "ubo", "->", "buffer", ".", "bindcode", "=", "GPU_buf_alloc", "(", ")", ";", "if", "(", "!", "ubo", "->", "buffer", ".", "bindcode", ")", "{", "if", "(", "err_out", ")", "{", "BLI_strncpy", "(", "err_out", ",", "\"", "\"", ",", "256", ")", ";", "}", "GPU_uniformbuffer_free", "(", "&", "ubo", "->", "buffer", ")", ";", "return", "NULL", ";", "}", "if", "(", "ubo", "->", "buffer", ".", "size", ">", "GPU_max_ubo_size", "(", ")", ")", "{", "if", "(", "err_out", ")", "{", "BLI_strncpy", "(", "err_out", ",", "\"", "\"", ",", "256", ")", ";", "}", "GPU_uniformbuffer_free", "(", "&", "ubo", "->", "buffer", ")", ";", "return", "NULL", ";", "}", "gpu_uniformbuffer_inputs_sort", "(", "inputs", ")", ";", "for", "(", "LinkData", "*", "link", "=", "inputs", "->", "first", ";", "link", ";", "link", "=", "link", "->", "next", ")", "{", "const", "eGPUType", "gputype", "=", "get_padded_gpu_type", "(", "link", ")", ";", "ubo", "->", "buffer", ".", "size", "+=", "gputype", "*", "sizeof", "(", "float", ")", ";", "}", "ubo", "->", "buffer", ".", "size", "=", "(", "(", "ubo", "->", "buffer", ".", "size", "+", "15", ")", "/", "16", ")", "*", "16", ";", "ubo", "->", "data", "=", "MEM_mallocN", "(", "ubo", "->", "buffer", ".", "size", ",", "__func__", ")", ";", "float", "*", "offset", "=", "ubo", "->", "data", ";", "for", "(", "LinkData", "*", "link", "=", "inputs", "->", "first", ";", "link", ";", "link", "=", "link", "->", "next", ")", "{", "GPUInput", "*", "input", "=", "link", "->", "data", ";", "memcpy", "(", "offset", ",", "input", "->", "vec", ",", "input", "->", "type", "*", "sizeof", "(", "float", ")", ")", ";", "offset", "+=", "get_padded_gpu_type", "(", "link", ")", ";", "}", "return", "&", "ubo", "->", "buffer", ";", "}" ]
Create dynamic UBO from parameters Return NULL if failed to create or if \param inputs: is empty.
[ "Create", "dynamic", "UBO", "from", "parameters", "Return", "NULL", "if", "failed", "to", "create", "or", "if", "\\", "param", "inputs", ":", "is", "empty", "." ]
[ "/* There is no point on creating an UBO if there is no arguments. */", "/* Generate Buffer object. */", "/* Make sure we comply to the ubo alignment requirements. */", "/* Round up to size of vec4 */", "/* Allocate the data. */", "/* Now that we know the total ubo size we can start populating it. */", "/* Note since we may create the UBOs in the CPU in a different thread than the main drawing one,\n * we don't create the UBO in the GPU here. This will happen when we first bind the UBO.\n */" ]
[ { "param": "inputs", "type": "ListBase" }, { "param": "err_out", "type": "char" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "inputs", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "err_out", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46dcc6c6f781612ce47b9bbf1de1274718c58542
DemonRem/blender
source/blender/gpu/intern/gpu_uniformbuffer.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
inputs_cmp
int
static int inputs_cmp(const void *a, const void *b) { const LinkData *link_a = a, *link_b = b; const GPUInput *input_a = link_a->data, *input_b = link_b->data; return input_a->type < input_b->type ? 1 : 0; }
/** * Returns 1 if the first item should be after second item. * We make sure the vec4 uniforms come first. */
Returns 1 if the first item should be after second item. We make sure the vec4 uniforms come first.
[ "Returns", "1", "if", "the", "first", "item", "should", "be", "after", "second", "item", ".", "We", "make", "sure", "the", "vec4", "uniforms", "come", "first", "." ]
static int inputs_cmp(const void *a, const void *b) { const LinkData *link_a = a, *link_b = b; const GPUInput *input_a = link_a->data, *input_b = link_b->data; return input_a->type < input_b->type ? 1 : 0; }
[ "static", "int", "inputs_cmp", "(", "const", "void", "*", "a", ",", "const", "void", "*", "b", ")", "{", "const", "LinkData", "*", "link_a", "=", "a", ",", "*", "link_b", "=", "b", ";", "const", "GPUInput", "*", "input_a", "=", "link_a", "->", "data", ",", "*", "input_b", "=", "link_b", "->", "data", ";", "return", "input_a", "->", "type", "<", "input_b", "->", "type", "?", "1", ":", "0", ";", "}" ]
Returns 1 if the first item should be after second item.
[ "Returns", "1", "if", "the", "first", "item", "should", "be", "after", "second", "item", "." ]
[]
[ { "param": "a", "type": "void" }, { "param": "b", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "b", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46dcc6c6f781612ce47b9bbf1de1274718c58542
DemonRem/blender
source/blender/gpu/intern/gpu_uniformbuffer.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpu_uniformbuffer_inputs_sort
void
static void gpu_uniformbuffer_inputs_sort(ListBase *inputs) { /* Order them as mat4, vec4, vec3, vec2, float. */ BLI_listbase_sort(inputs, inputs_cmp); /* Creates a lookup table for the different types; */ LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL}; eGPUType cur_type = MAX_UBO_GPU_TYPE + 1; for (LinkData *link = inputs->first; link; link = link->next) { GPUInput *input = link->data; if (input->type == GPU_MAT3) { /* Alignment for mat3 is not handled currently, so not supported */ BLI_assert(!"mat3 not supported in UBO"); continue; } else if (input->type > MAX_UBO_GPU_TYPE) { BLI_assert(!"GPU type not supported in UBO"); continue; } if (input->type == cur_type) { continue; } else { inputs_lookup[input->type] = link; cur_type = input->type; } } /* If there is no GPU_VEC3 there is no need for alignment. */ if (inputs_lookup[GPU_VEC3] == NULL) { return; } LinkData *link = inputs_lookup[GPU_VEC3]; while (link != NULL && ((GPUInput *)link->data)->type == GPU_VEC3) { LinkData *link_next = link->next; /* If GPU_VEC3 is followed by nothing or a GPU_FLOAT, no need for alignment. */ if ((link_next == NULL) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) { break; } /* If there is a float, move it next to current vec3. */ if (inputs_lookup[GPU_FLOAT] != NULL) { LinkData *float_input = inputs_lookup[GPU_FLOAT]; inputs_lookup[GPU_FLOAT] = float_input->next; BLI_remlink(inputs, float_input); BLI_insertlinkafter(inputs, link, float_input); } link = link_next; } }
/** * Make sure we respect the expected alignment of UBOs. * mat4, vec4, pad vec3 as vec4, then vec2, then floats. */
Make sure we respect the expected alignment of UBOs. mat4, vec4, pad vec3 as vec4, then vec2, then floats.
[ "Make", "sure", "we", "respect", "the", "expected", "alignment", "of", "UBOs", ".", "mat4", "vec4", "pad", "vec3", "as", "vec4", "then", "vec2", "then", "floats", "." ]
static void gpu_uniformbuffer_inputs_sort(ListBase *inputs) { BLI_listbase_sort(inputs, inputs_cmp); LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL}; eGPUType cur_type = MAX_UBO_GPU_TYPE + 1; for (LinkData *link = inputs->first; link; link = link->next) { GPUInput *input = link->data; if (input->type == GPU_MAT3) { BLI_assert(!"mat3 not supported in UBO"); continue; } else if (input->type > MAX_UBO_GPU_TYPE) { BLI_assert(!"GPU type not supported in UBO"); continue; } if (input->type == cur_type) { continue; } else { inputs_lookup[input->type] = link; cur_type = input->type; } } if (inputs_lookup[GPU_VEC3] == NULL) { return; } LinkData *link = inputs_lookup[GPU_VEC3]; while (link != NULL && ((GPUInput *)link->data)->type == GPU_VEC3) { LinkData *link_next = link->next; if ((link_next == NULL) || ((GPUInput *)link_next->data)->type == GPU_FLOAT) { break; } if (inputs_lookup[GPU_FLOAT] != NULL) { LinkData *float_input = inputs_lookup[GPU_FLOAT]; inputs_lookup[GPU_FLOAT] = float_input->next; BLI_remlink(inputs, float_input); BLI_insertlinkafter(inputs, link, float_input); } link = link_next; } }
[ "static", "void", "gpu_uniformbuffer_inputs_sort", "(", "ListBase", "*", "inputs", ")", "{", "BLI_listbase_sort", "(", "inputs", ",", "inputs_cmp", ")", ";", "LinkData", "*", "inputs_lookup", "[", "MAX_UBO_GPU_TYPE", "+", "1", "]", "=", "{", "NULL", "}", ";", "eGPUType", "cur_type", "=", "MAX_UBO_GPU_TYPE", "+", "1", ";", "for", "(", "LinkData", "*", "link", "=", "inputs", "->", "first", ";", "link", ";", "link", "=", "link", "->", "next", ")", "{", "GPUInput", "*", "input", "=", "link", "->", "data", ";", "if", "(", "input", "->", "type", "==", "GPU_MAT3", ")", "{", "BLI_assert", "(", "!", "\"", "\"", ")", ";", "continue", ";", "}", "else", "if", "(", "input", "->", "type", ">", "MAX_UBO_GPU_TYPE", ")", "{", "BLI_assert", "(", "!", "\"", "\"", ")", ";", "continue", ";", "}", "if", "(", "input", "->", "type", "==", "cur_type", ")", "{", "continue", ";", "}", "else", "{", "inputs_lookup", "[", "input", "->", "type", "]", "=", "link", ";", "cur_type", "=", "input", "->", "type", ";", "}", "}", "if", "(", "inputs_lookup", "[", "GPU_VEC3", "]", "==", "NULL", ")", "{", "return", ";", "}", "LinkData", "*", "link", "=", "inputs_lookup", "[", "GPU_VEC3", "]", ";", "while", "(", "link", "!=", "NULL", "&&", "(", "(", "GPUInput", "*", ")", "link", "->", "data", ")", "->", "type", "==", "GPU_VEC3", ")", "{", "LinkData", "*", "link_next", "=", "link", "->", "next", ";", "if", "(", "(", "link_next", "==", "NULL", ")", "||", "(", "(", "GPUInput", "*", ")", "link_next", "->", "data", ")", "->", "type", "==", "GPU_FLOAT", ")", "{", "break", ";", "}", "if", "(", "inputs_lookup", "[", "GPU_FLOAT", "]", "!=", "NULL", ")", "{", "LinkData", "*", "float_input", "=", "inputs_lookup", "[", "GPU_FLOAT", "]", ";", "inputs_lookup", "[", "GPU_FLOAT", "]", "=", "float_input", "->", "next", ";", "BLI_remlink", "(", "inputs", ",", "float_input", ")", ";", "BLI_insertlinkafter", "(", "inputs", ",", "link", ",", "float_input", ")", ";", "}", "link", "=", "link_next", ";", "}", "}" ]
Make sure we respect the expected alignment of UBOs.
[ "Make", "sure", "we", "respect", "the", "expected", "alignment", "of", "UBOs", "." ]
[ "/* Order them as mat4, vec4, vec3, vec2, float. */", "/* Creates a lookup table for the different types; */", "/* Alignment for mat3 is not handled currently, so not supported */", "/* If there is no GPU_VEC3 there is no need for alignment. */", "/* If GPU_VEC3 is followed by nothing or a GPU_FLOAT, no need for alignment. */", "/* If there is a float, move it next to current vec3. */" ]
[ { "param": "inputs", "type": "ListBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "inputs", "type": "ListBase", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c030c551374beb43175bfb87e315f875626041dd
DemonRem/blender
source/blender/editors/object/object_relations.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
object_remove_parent_deform_modifiers
void
static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) { if (ELEM(par->type, OB_ARMATURE, OB_LATTICE, OB_CURVE)) { ModifierData *md, *mdn; /* assume that we only need to remove the first instance of matching deform modifier here */ for (md = ob->modifiers.first; md; md = mdn) { bool free = false; mdn = md->next; /* need to match types (modifier + parent) and references */ if ((md->type == eModifierType_Armature) && (par->type == OB_ARMATURE)) { ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->object == par) { free = true; } } else if ((md->type == eModifierType_Lattice) && (par->type == OB_LATTICE)) { LatticeModifierData *lmd = (LatticeModifierData *)md; if (lmd->object == par) { free = true; } } else if ((md->type == eModifierType_Curve) && (par->type == OB_CURVE)) { CurveModifierData *cmd = (CurveModifierData *)md; if (cmd->object == par) { free = true; } } /* free modifier if match */ if (free) { BLI_remlink(&ob->modifiers, md); modifier_free(md); } } } }
/* Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent */
Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent
[ "Helper", "for", "ED_object_parent_clear", "()", "-", "Remove", "deform", "-", "modifiers", "associated", "with", "parent" ]
static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) { if (ELEM(par->type, OB_ARMATURE, OB_LATTICE, OB_CURVE)) { ModifierData *md, *mdn; for (md = ob->modifiers.first; md; md = mdn) { bool free = false; mdn = md->next; if ((md->type == eModifierType_Armature) && (par->type == OB_ARMATURE)) { ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->object == par) { free = true; } } else if ((md->type == eModifierType_Lattice) && (par->type == OB_LATTICE)) { LatticeModifierData *lmd = (LatticeModifierData *)md; if (lmd->object == par) { free = true; } } else if ((md->type == eModifierType_Curve) && (par->type == OB_CURVE)) { CurveModifierData *cmd = (CurveModifierData *)md; if (cmd->object == par) { free = true; } } if (free) { BLI_remlink(&ob->modifiers, md); modifier_free(md); } } } }
[ "static", "void", "object_remove_parent_deform_modifiers", "(", "Object", "*", "ob", ",", "const", "Object", "*", "par", ")", "{", "if", "(", "ELEM", "(", "par", "->", "type", ",", "OB_ARMATURE", ",", "OB_LATTICE", ",", "OB_CURVE", ")", ")", "{", "ModifierData", "*", "md", ",", "*", "mdn", ";", "for", "(", "md", "=", "ob", "->", "modifiers", ".", "first", ";", "md", ";", "md", "=", "mdn", ")", "{", "bool", "free", "=", "false", ";", "mdn", "=", "md", "->", "next", ";", "if", "(", "(", "md", "->", "type", "==", "eModifierType_Armature", ")", "&&", "(", "par", "->", "type", "==", "OB_ARMATURE", ")", ")", "{", "ArmatureModifierData", "*", "amd", "=", "(", "ArmatureModifierData", "*", ")", "md", ";", "if", "(", "amd", "->", "object", "==", "par", ")", "{", "free", "=", "true", ";", "}", "}", "else", "if", "(", "(", "md", "->", "type", "==", "eModifierType_Lattice", ")", "&&", "(", "par", "->", "type", "==", "OB_LATTICE", ")", ")", "{", "LatticeModifierData", "*", "lmd", "=", "(", "LatticeModifierData", "*", ")", "md", ";", "if", "(", "lmd", "->", "object", "==", "par", ")", "{", "free", "=", "true", ";", "}", "}", "else", "if", "(", "(", "md", "->", "type", "==", "eModifierType_Curve", ")", "&&", "(", "par", "->", "type", "==", "OB_CURVE", ")", ")", "{", "CurveModifierData", "*", "cmd", "=", "(", "CurveModifierData", "*", ")", "md", ";", "if", "(", "cmd", "->", "object", "==", "par", ")", "{", "free", "=", "true", ";", "}", "}", "if", "(", "free", ")", "{", "BLI_remlink", "(", "&", "ob", "->", "modifiers", ",", "md", ")", ";", "modifier_free", "(", "md", ")", ";", "}", "}", "}", "}" ]
Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent
[ "Helper", "for", "ED_object_parent_clear", "()", "-", "Remove", "deform", "-", "modifiers", "associated", "with", "parent" ]
[ "/* assume that we only need to remove the first instance of matching deform modifier here */", "/* need to match types (modifier + parent) and references */", "/* free modifier if match */" ]
[ { "param": "ob", "type": "Object" }, { "param": "par", "type": "Object" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ob", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "par", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c030c551374beb43175bfb87e315f875626041dd
DemonRem/blender
source/blender/editors/object/object_relations.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
allow_make_links_data
bool
static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst) { switch (type) { case MAKE_LINKS_OBDATA: if (ob_src->type == ob_dst->type && ob_src->type != OB_EMPTY) { return true; } break; case MAKE_LINKS_MATERIALS: if (OB_TYPE_SUPPORT_MATERIAL(ob_src->type) && OB_TYPE_SUPPORT_MATERIAL(ob_dst->type)) { return true; } break; case MAKE_LINKS_DUPLICOLLECTION: if (ob_dst->type == OB_EMPTY) { return true; } break; case MAKE_LINKS_ANIMDATA: case MAKE_LINKS_GROUP: return true; case MAKE_LINKS_MODIFIERS: if (!ELEM(OB_EMPTY, ob_src->type, ob_dst->type)) { return true; } break; case MAKE_LINKS_FONTS: if ((ob_src->data != ob_dst->data) && (ob_src->type == OB_FONT) && (ob_dst->type == OB_FONT)) { return true; } break; } return false; }
/* Return true if make link data is allowed, false otherwise */
Return true if make link data is allowed, false otherwise
[ "Return", "true", "if", "make", "link", "data", "is", "allowed", "false", "otherwise" ]
static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst) { switch (type) { case MAKE_LINKS_OBDATA: if (ob_src->type == ob_dst->type && ob_src->type != OB_EMPTY) { return true; } break; case MAKE_LINKS_MATERIALS: if (OB_TYPE_SUPPORT_MATERIAL(ob_src->type) && OB_TYPE_SUPPORT_MATERIAL(ob_dst->type)) { return true; } break; case MAKE_LINKS_DUPLICOLLECTION: if (ob_dst->type == OB_EMPTY) { return true; } break; case MAKE_LINKS_ANIMDATA: case MAKE_LINKS_GROUP: return true; case MAKE_LINKS_MODIFIERS: if (!ELEM(OB_EMPTY, ob_src->type, ob_dst->type)) { return true; } break; case MAKE_LINKS_FONTS: if ((ob_src->data != ob_dst->data) && (ob_src->type == OB_FONT) && (ob_dst->type == OB_FONT)) { return true; } break; } return false; }
[ "static", "bool", "allow_make_links_data", "(", "const", "int", "type", ",", "Object", "*", "ob_src", ",", "Object", "*", "ob_dst", ")", "{", "switch", "(", "type", ")", "{", "case", "MAKE_LINKS_OBDATA", ":", "if", "(", "ob_src", "->", "type", "==", "ob_dst", "->", "type", "&&", "ob_src", "->", "type", "!=", "OB_EMPTY", ")", "{", "return", "true", ";", "}", "break", ";", "case", "MAKE_LINKS_MATERIALS", ":", "if", "(", "OB_TYPE_SUPPORT_MATERIAL", "(", "ob_src", "->", "type", ")", "&&", "OB_TYPE_SUPPORT_MATERIAL", "(", "ob_dst", "->", "type", ")", ")", "{", "return", "true", ";", "}", "break", ";", "case", "MAKE_LINKS_DUPLICOLLECTION", ":", "if", "(", "ob_dst", "->", "type", "==", "OB_EMPTY", ")", "{", "return", "true", ";", "}", "break", ";", "case", "MAKE_LINKS_ANIMDATA", ":", "case", "MAKE_LINKS_GROUP", ":", "return", "true", ";", "case", "MAKE_LINKS_MODIFIERS", ":", "if", "(", "!", "ELEM", "(", "OB_EMPTY", ",", "ob_src", "->", "type", ",", "ob_dst", "->", "type", ")", ")", "{", "return", "true", ";", "}", "break", ";", "case", "MAKE_LINKS_FONTS", ":", "if", "(", "(", "ob_src", "->", "data", "!=", "ob_dst", "->", "data", ")", "&&", "(", "ob_src", "->", "type", "==", "OB_FONT", ")", "&&", "(", "ob_dst", "->", "type", "==", "OB_FONT", ")", ")", "{", "return", "true", ";", "}", "break", ";", "}", "return", "false", ";", "}" ]
Return true if make link data is allowed, false otherwise
[ "Return", "true", "if", "make", "link", "data", "is", "allowed", "false", "otherwise" ]
[]
[ { "param": "type", "type": "int" }, { "param": "ob_src", "type": "Object" }, { "param": "ob_dst", "type": "Object" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob_src", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob_dst", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c030c551374beb43175bfb87e315f875626041dd
DemonRem/blender
source/blender/editors/object/object_relations.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
single_object_users
void
static void single_object_users( Main *bmain, Scene *scene, View3D *v3d, const int flag, const bool copy_collections) { /* duplicate all the objects of the scene (and matching collections, if required). */ Collection *master_collection = scene->master_collection; single_object_users_collection(bmain, scene, master_collection, flag, copy_collections, true); /* duplicate collections that consist entirely of duplicated objects */ /* XXX I guess that was designed for calls from 'make single user' operator. * But since copy_collection is always false then, was not doing anything. * And that kind of behavior should be added at operator level, * not in a utility function also used by rather different code. */ #if 0 if (copy_collections) { Collection *collection, *collectionn; for (collection = bmain->collections.first; collection; collection = collection->id.next) { bool all_duplicated = true; bool any_duplicated = false; for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { any_duplicated = true; if (cob->ob->id.newid == NULL) { all_duplicated = false; break; } } if (any_duplicated && all_duplicated) { // TODO: test if this works, with child collections .. collectionn = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection)); for (CollectionObject *cob = collectionn->gobject.first; cob; cob = cob->next) { cob->ob = (Object *)cob->ob->id.newid; } } } } #endif /* Collection and object pointers in collections */ libblock_relink_collection(master_collection); /* collection pointers in scene */ BKE_scene_groups_relink(scene); /* active camera */ ID_NEW_REMAP(scene->camera); if (v3d) { ID_NEW_REMAP(v3d->camera); } /* Camera pointers of markers. */ for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { ID_NEW_REMAP(marker->camera); } /* Making single user may affect other scenes if they share * with current one some collections in their ViewLayer. */ BKE_main_collection_sync(bmain); }
/* Warning, sets ID->newid pointers of objects and collections, but does not clear them. */
Warning, sets ID->newid pointers of objects and collections, but does not clear them.
[ "Warning", "sets", "ID", "-", ">", "newid", "pointers", "of", "objects", "and", "collections", "but", "does", "not", "clear", "them", "." ]
static void single_object_users( Main *bmain, Scene *scene, View3D *v3d, const int flag, const bool copy_collections) { Collection *master_collection = scene->master_collection; single_object_users_collection(bmain, scene, master_collection, flag, copy_collections, true); #if 0 if (copy_collections) { Collection *collection, *collectionn; for (collection = bmain->collections.first; collection; collection = collection->id.next) { bool all_duplicated = true; bool any_duplicated = false; for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) { any_duplicated = true; if (cob->ob->id.newid == NULL) { all_duplicated = false; break; } } if (any_duplicated && all_duplicated) { collectionn = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection)); for (CollectionObject *cob = collectionn->gobject.first; cob; cob = cob->next) { cob->ob = (Object *)cob->ob->id.newid; } } } } #endif libblock_relink_collection(master_collection); BKE_scene_groups_relink(scene); ID_NEW_REMAP(scene->camera); if (v3d) { ID_NEW_REMAP(v3d->camera); } for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) { ID_NEW_REMAP(marker->camera); } BKE_main_collection_sync(bmain); }
[ "static", "void", "single_object_users", "(", "Main", "*", "bmain", ",", "Scene", "*", "scene", ",", "View3D", "*", "v3d", ",", "const", "int", "flag", ",", "const", "bool", "copy_collections", ")", "{", "Collection", "*", "master_collection", "=", "scene", "->", "master_collection", ";", "single_object_users_collection", "(", "bmain", ",", "scene", ",", "master_collection", ",", "flag", ",", "copy_collections", ",", "true", ")", ";", "#if", "0", "\n", "if", "(", "copy_collections", ")", "{", "Collection", "*", "collection", ",", "*", "collectionn", ";", "for", "(", "collection", "=", "bmain", "->", "collections", ".", "first", ";", "collection", ";", "collection", "=", "collection", "->", "id", ".", "next", ")", "{", "bool", "all_duplicated", "=", "true", ";", "bool", "any_duplicated", "=", "false", ";", "for", "(", "CollectionObject", "*", "cob", "=", "collection", "->", "gobject", ".", "first", ";", "cob", ";", "cob", "=", "cob", "->", "next", ")", "{", "any_duplicated", "=", "true", ";", "if", "(", "cob", "->", "ob", "->", "id", ".", "newid", "==", "NULL", ")", "{", "all_duplicated", "=", "false", ";", "break", ";", "}", "}", "if", "(", "any_duplicated", "&&", "all_duplicated", ")", "{", "collectionn", "=", "ID_NEW_SET", "(", "collection", ",", "BKE_collection_copy", "(", "bmain", ",", "NULL", ",", "collection", ")", ")", ";", "for", "(", "CollectionObject", "*", "cob", "=", "collectionn", "->", "gobject", ".", "first", ";", "cob", ";", "cob", "=", "cob", "->", "next", ")", "{", "cob", "->", "ob", "=", "(", "Object", "*", ")", "cob", "->", "ob", "->", "id", ".", "newid", ";", "}", "}", "}", "}", "#endif", "libblock_relink_collection", "(", "master_collection", ")", ";", "BKE_scene_groups_relink", "(", "scene", ")", ";", "ID_NEW_REMAP", "(", "scene", "->", "camera", ")", ";", "if", "(", "v3d", ")", "{", "ID_NEW_REMAP", "(", "v3d", "->", "camera", ")", ";", "}", "for", "(", "TimeMarker", "*", "marker", "=", "scene", "->", "markers", ".", "first", ";", "marker", ";", "marker", "=", "marker", "->", "next", ")", "{", "ID_NEW_REMAP", "(", "marker", "->", "camera", ")", ";", "}", "BKE_main_collection_sync", "(", "bmain", ")", ";", "}" ]
Warning, sets ID->newid pointers of objects and collections, but does not clear them.
[ "Warning", "sets", "ID", "-", ">", "newid", "pointers", "of", "objects", "and", "collections", "but", "does", "not", "clear", "them", "." ]
[ "/* duplicate all the objects of the scene (and matching collections, if required). */", "/* duplicate collections that consist entirely of duplicated objects */", "/* XXX I guess that was designed for calls from 'make single user' operator.\n * But since copy_collection is always false then, was not doing anything.\n * And that kind of behavior should be added at operator level,\n * not in a utility function also used by rather different code. */", "// TODO: test if this works, with child collections ..", "/* Collection and object pointers in collections */", "/* collection pointers in scene */", "/* active camera */", "/* Camera pointers of markers. */", "/* Making single user may affect other scenes if they share\n * with current one some collections in their ViewLayer. */" ]
[ { "param": "bmain", "type": "Main" }, { "param": "scene", "type": "Scene" }, { "param": "v3d", "type": "View3D" }, { "param": "flag", "type": "int" }, { "param": "copy_collections", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bmain", "type": "Main", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scene", "type": "Scene", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v3d", "type": "View3D", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flag", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "copy_collections", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c030c551374beb43175bfb87e315f875626041dd
DemonRem/blender
source/blender/editors/object/object_relations.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
make_local_animdata_tag
void
static void make_local_animdata_tag(AnimData *adt) { if (adt) { /* Actions - Active and Temp */ if (adt->action) { adt->action->id.tag &= ~LIB_TAG_PRE_EXISTING; } if (adt->tmpact) { adt->tmpact->id.tag &= ~LIB_TAG_PRE_EXISTING; } /* Drivers */ /* TODO: need to handle the ID-targets too? */ /* NLA Data */ for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { make_local_animdata_tag_strips(&nlt->strips); } } }
/* Tag all actions used by given animdata to be made local. */
Tag all actions used by given animdata to be made local.
[ "Tag", "all", "actions", "used", "by", "given", "animdata", "to", "be", "made", "local", "." ]
static void make_local_animdata_tag(AnimData *adt) { if (adt) { if (adt->action) { adt->action->id.tag &= ~LIB_TAG_PRE_EXISTING; } if (adt->tmpact) { adt->tmpact->id.tag &= ~LIB_TAG_PRE_EXISTING; } for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { make_local_animdata_tag_strips(&nlt->strips); } } }
[ "static", "void", "make_local_animdata_tag", "(", "AnimData", "*", "adt", ")", "{", "if", "(", "adt", ")", "{", "if", "(", "adt", "->", "action", ")", "{", "adt", "->", "action", "->", "id", ".", "tag", "&=", "~", "LIB_TAG_PRE_EXISTING", ";", "}", "if", "(", "adt", "->", "tmpact", ")", "{", "adt", "->", "tmpact", "->", "id", ".", "tag", "&=", "~", "LIB_TAG_PRE_EXISTING", ";", "}", "for", "(", "NlaTrack", "*", "nlt", "=", "adt", "->", "nla_tracks", ".", "first", ";", "nlt", ";", "nlt", "=", "nlt", "->", "next", ")", "{", "make_local_animdata_tag_strips", "(", "&", "nlt", "->", "strips", ")", ";", "}", "}", "}" ]
Tag all actions used by given animdata to be made local.
[ "Tag", "all", "actions", "used", "by", "given", "animdata", "to", "be", "made", "local", "." ]
[ "/* Actions - Active and Temp */", "/* Drivers */", "/* TODO: need to handle the ID-targets too? */", "/* NLA Data */" ]
[ { "param": "adt", "type": "AnimData" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "adt", "type": "AnimData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
c030c551374beb43175bfb87e315f875626041dd
DemonRem/blender
source/blender/editors/object/object_relations.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
make_override_library_invoke
int
static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); Object *obact = ED_object_active_context(C); /* Sanity checks. */ if (!scene || ID_IS_LINKED(scene) || !obact) { return OPERATOR_CANCELLED; } /* Get object to work on - use a menu if we need to... */ if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_LINKED(obact->instance_collection)) { /* Gives menu with list of objects in group. */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } else if (ID_IS_LINKED(obact)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); /* Create operator menu item with relevant properties filled in. */ PointerRNA opptr_dummy; uiItemFullO_ptr( layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, 0, &opptr_dummy); /* Present the menu and be done... */ UI_popup_menu_end(C, pup); /* This invoke just calls another instance of this operator... */ return OPERATOR_INTERFACE; } else { /* Error.. cannot continue. */ BKE_report(op->reports, RPT_ERROR, "Can only make library override for a referenced object or collection"); return OPERATOR_CANCELLED; } }
/* Set the object to override. */
Set the object to override.
[ "Set", "the", "object", "to", "override", "." ]
static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); Object *obact = ED_object_active_context(C); if (!scene || ID_IS_LINKED(scene) || !obact) { return OPERATOR_CANCELLED; } if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && ID_IS_LINKED(obact->instance_collection)) { WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } else if (ID_IS_LINKED(obact)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); PointerRNA opptr_dummy; uiItemFullO_ptr( layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, 0, &opptr_dummy); UI_popup_menu_end(C, pup); return OPERATOR_INTERFACE; } else { BKE_report(op->reports, RPT_ERROR, "Can only make library override for a referenced object or collection"); return OPERATOR_CANCELLED; } }
[ "static", "int", "make_override_library_invoke", "(", "bContext", "*", "C", ",", "wmOperator", "*", "op", ",", "const", "wmEvent", "*", "event", ")", "{", "Scene", "*", "scene", "=", "CTX_data_scene", "(", "C", ")", ";", "Object", "*", "obact", "=", "ED_object_active_context", "(", "C", ")", ";", "if", "(", "!", "scene", "||", "ID_IS_LINKED", "(", "scene", ")", "||", "!", "obact", ")", "{", "return", "OPERATOR_CANCELLED", ";", "}", "if", "(", "!", "ID_IS_LINKED", "(", "obact", ")", "&&", "obact", "->", "instance_collection", "!=", "NULL", "&&", "ID_IS_LINKED", "(", "obact", "->", "instance_collection", ")", ")", "{", "WM_enum_search_invoke", "(", "C", ",", "op", ",", "event", ")", ";", "return", "OPERATOR_CANCELLED", ";", "}", "else", "if", "(", "ID_IS_LINKED", "(", "obact", ")", ")", "{", "uiPopupMenu", "*", "pup", "=", "UI_popup_menu_begin", "(", "C", ",", "IFACE_", "(", "\"", "\"", ")", ",", "ICON_QUESTION", ")", ";", "uiLayout", "*", "layout", "=", "UI_popup_menu_layout", "(", "pup", ")", ";", "PointerRNA", "opptr_dummy", ";", "uiItemFullO_ptr", "(", "layout", ",", "op", "->", "type", ",", "op", "->", "type", "->", "name", ",", "ICON_NONE", ",", "NULL", ",", "WM_OP_EXEC_REGION_WIN", ",", "0", ",", "&", "opptr_dummy", ")", ";", "UI_popup_menu_end", "(", "C", ",", "pup", ")", ";", "return", "OPERATOR_INTERFACE", ";", "}", "else", "{", "BKE_report", "(", "op", "->", "reports", ",", "RPT_ERROR", ",", "\"", "\"", ")", ";", "return", "OPERATOR_CANCELLED", ";", "}", "}" ]
Set the object to override.
[ "Set", "the", "object", "to", "override", "." ]
[ "/* Sanity checks. */", "/* Get object to work on - use a menu if we need to... */", "/* Gives menu with list of objects in group. */", "/* Create operator menu item with relevant properties filled in. */", "/* Present the menu and be done... */", "/* This invoke just calls another instance of this operator... */", "/* Error.. cannot continue. */" ]
[ { "param": "C", "type": "bContext" }, { "param": "op", "type": "wmOperator" }, { "param": "event", "type": "wmEvent" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "C", "type": "bContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "op", "type": "wmOperator", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "event", "type": "wmEvent", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
46c46a1440f150413a9f08fec07a33b8db9ea842
DemonRem/blender
source/blender/blenlib/BLI_vector.h
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
clear
void
void clear() { destruct_n(m_begin, this->size()); m_end = m_begin; UPDATE_VECTOR_SIZE(this); }
/** * Afterwards the vector has 0 elements, but will still have * memory to be refilled again. */
Afterwards the vector has 0 elements, but will still have memory to be refilled again.
[ "Afterwards", "the", "vector", "has", "0", "elements", "but", "will", "still", "have", "memory", "to", "be", "refilled", "again", "." ]
void clear() { destruct_n(m_begin, this->size()); m_end = m_begin; UPDATE_VECTOR_SIZE(this); }
[ "void", "clear", "(", ")", "{", "destruct_n", "(", "m_begin", ",", "this", "->", "size", "(", ")", ")", ";", "m_end", "=", "m_begin", ";", "UPDATE_VECTOR_SIZE", "(", "this", ")", ";", "}" ]
Afterwards the vector has 0 elements, but will still have memory to be refilled again.
[ "Afterwards", "the", "vector", "has", "0", "elements", "but", "will", "still", "have", "memory", "to", "be", "refilled", "again", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46c46a1440f150413a9f08fec07a33b8db9ea842
DemonRem/blender
source/blender/blenlib/BLI_vector.h
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
clear_and_make_small
void
void clear_and_make_small() { destruct_n(m_begin, this->size()); if (!this->is_small()) { m_allocator.deallocate(m_begin); } m_begin = this->small_buffer(); m_end = m_begin; m_capacity_end = m_begin + N; UPDATE_VECTOR_SIZE(this); }
/** * Afterwards the vector has 0 elements and any allocated memory * will be freed. */
Afterwards the vector has 0 elements and any allocated memory will be freed.
[ "Afterwards", "the", "vector", "has", "0", "elements", "and", "any", "allocated", "memory", "will", "be", "freed", "." ]
void clear_and_make_small() { destruct_n(m_begin, this->size()); if (!this->is_small()) { m_allocator.deallocate(m_begin); } m_begin = this->small_buffer(); m_end = m_begin; m_capacity_end = m_begin + N; UPDATE_VECTOR_SIZE(this); }
[ "void", "clear_and_make_small", "(", ")", "{", "destruct_n", "(", "m_begin", ",", "this", "->", "size", "(", ")", ")", ";", "if", "(", "!", "this", "->", "is_small", "(", ")", ")", "{", "m_allocator", ".", "deallocate", "(", "m_begin", ")", ";", "}", "m_begin", "=", "this", "->", "small_buffer", "(", ")", ";", "m_end", "=", "m_begin", ";", "m_capacity_end", "=", "m_begin", "+", "N", ";", "UPDATE_VECTOR_SIZE", "(", "this", ")", ";", "}" ]
Afterwards the vector has 0 elements and any allocated memory will be freed.
[ "Afterwards", "the", "vector", "has", "0", "elements", "and", "any", "allocated", "memory", "will", "be", "freed", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
46c46a1440f150413a9f08fec07a33b8db9ea842
DemonRem/blender
source/blender/blenlib/BLI_vector.h
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
remove_last
void
void remove_last() { BLI_assert(!this->empty()); m_end--; destruct(m_end); UPDATE_VECTOR_SIZE(this); }
/** * Deconstructs the last element and decreases the size by one. * This will assert when the vector is empty. */
Deconstructs the last element and decreases the size by one. This will assert when the vector is empty.
[ "Deconstructs", "the", "last", "element", "and", "decreases", "the", "size", "by", "one", ".", "This", "will", "assert", "when", "the", "vector", "is", "empty", "." ]
void remove_last() { BLI_assert(!this->empty()); m_end--; destruct(m_end); UPDATE_VECTOR_SIZE(this); }
[ "void", "remove_last", "(", ")", "{", "BLI_assert", "(", "!", "this", "->", "empty", "(", ")", ")", ";", "m_end", "--", ";", "destruct", "(", "m_end", ")", ";", "UPDATE_VECTOR_SIZE", "(", "this", ")", ";", "}" ]
Deconstructs the last element and decreases the size by one.
[ "Deconstructs", "the", "last", "element", "and", "decreases", "the", "size", "by", "one", "." ]
[]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f9df1342bf8e246044b66ef0cc2f777875777556
DemonRem/blender
source/blender/draw/engines/gpencil/gpencil_cache_utils.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_has_noninstanced_object
bool
static bool gpencil_has_noninstanced_object(Object *ob_instance) { const DRWContextState *draw_ctx = DRW_context_state_get(); const ViewLayer *view_layer = draw_ctx->view_layer; Object *ob = NULL; for (Base *base = view_layer->object_bases.first; base; base = base->next) { ob = base->object; if (ob->type != OB_GPENCIL) { continue; } /* is not duplicated and the name is equals */ if ((ob->base_flag & BASE_FROM_DUPLI) == 0) { if (STREQ(ob->id.name, ob_instance->id.name)) { return true; } } } return false; }
/* verify if exist a non instanced version of the object */
verify if exist a non instanced version of the object
[ "verify", "if", "exist", "a", "non", "instanced", "version", "of", "the", "object" ]
static bool gpencil_has_noninstanced_object(Object *ob_instance) { const DRWContextState *draw_ctx = DRW_context_state_get(); const ViewLayer *view_layer = draw_ctx->view_layer; Object *ob = NULL; for (Base *base = view_layer->object_bases.first; base; base = base->next) { ob = base->object; if (ob->type != OB_GPENCIL) { continue; } if ((ob->base_flag & BASE_FROM_DUPLI) == 0) { if (STREQ(ob->id.name, ob_instance->id.name)) { return true; } } } return false; }
[ "static", "bool", "gpencil_has_noninstanced_object", "(", "Object", "*", "ob_instance", ")", "{", "const", "DRWContextState", "*", "draw_ctx", "=", "DRW_context_state_get", "(", ")", ";", "const", "ViewLayer", "*", "view_layer", "=", "draw_ctx", "->", "view_layer", ";", "Object", "*", "ob", "=", "NULL", ";", "for", "(", "Base", "*", "base", "=", "view_layer", "->", "object_bases", ".", "first", ";", "base", ";", "base", "=", "base", "->", "next", ")", "{", "ob", "=", "base", "->", "object", ";", "if", "(", "ob", "->", "type", "!=", "OB_GPENCIL", ")", "{", "continue", ";", "}", "if", "(", "(", "ob", "->", "base_flag", "&", "BASE_FROM_DUPLI", ")", "==", "0", ")", "{", "if", "(", "STREQ", "(", "ob", "->", "id", ".", "name", ",", "ob_instance", "->", "id", ".", "name", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
verify if exist a non instanced version of the object
[ "verify", "if", "exist", "a", "non", "instanced", "version", "of", "the", "object" ]
[ "/* is not duplicated and the name is equals */" ]
[ { "param": "ob_instance", "type": "Object" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ob_instance", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f9df1342bf8e246044b66ef0cc2f777875777556
DemonRem/blender
source/blender/draw/engines/gpencil/gpencil_cache_utils.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_object_cache_add
tGPencilObjectCache
tGPencilObjectCache *gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, int *gp_cache_size, int *gp_cache_used) { const DRWContextState *draw_ctx = DRW_context_state_get(); tGPencilObjectCache *cache_elem = NULL; RegionView3D *rv3d = draw_ctx->rv3d; View3D *v3d = draw_ctx->v3d; tGPencilObjectCache *p = NULL; /* By default a cache is created with one block with a predefined number of free slots, * if the size is not enough, the cache is reallocated adding a new block of free slots. * This is done in order to keep cache small. */ if (*gp_cache_used + 1 > *gp_cache_size) { if ((*gp_cache_size == 0) || (cache_array == NULL)) { p = MEM_callocN(sizeof(struct tGPencilObjectCache) * GP_CACHE_BLOCK_SIZE, "tGPencilObjectCache"); *gp_cache_size = GP_CACHE_BLOCK_SIZE; } else { *gp_cache_size += GP_CACHE_BLOCK_SIZE; p = MEM_recallocN(cache_array, sizeof(struct tGPencilObjectCache) * *gp_cache_size); } cache_array = p; } /* zero out all pointers */ cache_elem = &cache_array[*gp_cache_used]; memset(cache_elem, 0, sizeof(*cache_elem)); cache_elem->ob = ob; cache_elem->gpd = (bGPdata *)ob->data; cache_elem->name = BKE_id_to_unique_string_key(&ob->id); copy_v3_v3(cache_elem->loc, ob->obmat[3]); copy_m4_m4(cache_elem->obmat, ob->obmat); cache_elem->idx = *gp_cache_used; /* object is duplicated (particle) */ if (ob->base_flag & BASE_FROM_DUPLI) { /* Check if the original object is not in the viewlayer * and cannot be managed as dupli. This is slower, but required to keep * the particle drawing FPS and display instanced objects in scene * without the original object */ bool has_original = gpencil_has_noninstanced_object(ob); cache_elem->is_dup_ob = (has_original) ? ob->base_flag & BASE_FROM_DUPLI : false; } else { cache_elem->is_dup_ob = false; } cache_elem->scale = mat4_to_scale(ob->obmat); /* save FXs */ cache_elem->pixfactor = cache_elem->gpd->pixfactor; cache_elem->shader_fx = ob->shader_fx; /* save wire mode (object mode is always primary option) */ if (ob->dt == OB_WIRE) { cache_elem->shading_type[0] = (int)OB_WIRE; } else { if (v3d) { cache_elem->shading_type[0] = (int)v3d->shading.type; } } /* shgrp array */ cache_elem->tot_layers = 0; int totgpl = BLI_listbase_count(&cache_elem->gpd->layers); if (totgpl > 0) { cache_elem->shgrp_array = MEM_callocN(sizeof(tGPencilObjectCache_shgrp) * totgpl, __func__); } /* calculate zdepth from point of view */ float zdepth = 0.0; if (rv3d) { if (rv3d->is_persp) { zdepth = ED_view3d_calc_zfac(rv3d, ob->obmat[3], NULL); } else { zdepth = -dot_v3v3(rv3d->viewinv[2], ob->obmat[3]); } } else { /* In render mode, rv3d is not available, so use the distance to camera. * The real distance is not important, but the relative distance to the camera plane * in order to sort by z_depth of the objects */ float vn[3] = {0.0f, 0.0f, -1.0f}; /* always face down */ float plane_cam[4]; struct Object *camera = draw_ctx->scene->camera; if (camera) { mul_m4_v3(camera->obmat, vn); normalize_v3(vn); plane_from_point_normal_v3(plane_cam, camera->loc, vn); zdepth = dist_squared_to_plane_v3(ob->obmat[3], plane_cam); } } cache_elem->zdepth = zdepth; /* increase slots used in cache */ (*gp_cache_used)++; return cache_array; }
/* add a gpencil object to cache to defer drawing */
add a gpencil object to cache to defer drawing
[ "add", "a", "gpencil", "object", "to", "cache", "to", "defer", "drawing" ]
tGPencilObjectCache *gpencil_object_cache_add(tGPencilObjectCache *cache_array, Object *ob, int *gp_cache_size, int *gp_cache_used) { const DRWContextState *draw_ctx = DRW_context_state_get(); tGPencilObjectCache *cache_elem = NULL; RegionView3D *rv3d = draw_ctx->rv3d; View3D *v3d = draw_ctx->v3d; tGPencilObjectCache *p = NULL; if (*gp_cache_used + 1 > *gp_cache_size) { if ((*gp_cache_size == 0) || (cache_array == NULL)) { p = MEM_callocN(sizeof(struct tGPencilObjectCache) * GP_CACHE_BLOCK_SIZE, "tGPencilObjectCache"); *gp_cache_size = GP_CACHE_BLOCK_SIZE; } else { *gp_cache_size += GP_CACHE_BLOCK_SIZE; p = MEM_recallocN(cache_array, sizeof(struct tGPencilObjectCache) * *gp_cache_size); } cache_array = p; } cache_elem = &cache_array[*gp_cache_used]; memset(cache_elem, 0, sizeof(*cache_elem)); cache_elem->ob = ob; cache_elem->gpd = (bGPdata *)ob->data; cache_elem->name = BKE_id_to_unique_string_key(&ob->id); copy_v3_v3(cache_elem->loc, ob->obmat[3]); copy_m4_m4(cache_elem->obmat, ob->obmat); cache_elem->idx = *gp_cache_used; if (ob->base_flag & BASE_FROM_DUPLI) { bool has_original = gpencil_has_noninstanced_object(ob); cache_elem->is_dup_ob = (has_original) ? ob->base_flag & BASE_FROM_DUPLI : false; } else { cache_elem->is_dup_ob = false; } cache_elem->scale = mat4_to_scale(ob->obmat); cache_elem->pixfactor = cache_elem->gpd->pixfactor; cache_elem->shader_fx = ob->shader_fx; if (ob->dt == OB_WIRE) { cache_elem->shading_type[0] = (int)OB_WIRE; } else { if (v3d) { cache_elem->shading_type[0] = (int)v3d->shading.type; } } cache_elem->tot_layers = 0; int totgpl = BLI_listbase_count(&cache_elem->gpd->layers); if (totgpl > 0) { cache_elem->shgrp_array = MEM_callocN(sizeof(tGPencilObjectCache_shgrp) * totgpl, __func__); } float zdepth = 0.0; if (rv3d) { if (rv3d->is_persp) { zdepth = ED_view3d_calc_zfac(rv3d, ob->obmat[3], NULL); } else { zdepth = -dot_v3v3(rv3d->viewinv[2], ob->obmat[3]); } } else { float vn[3] = {0.0f, 0.0f, -1.0f}; float plane_cam[4]; struct Object *camera = draw_ctx->scene->camera; if (camera) { mul_m4_v3(camera->obmat, vn); normalize_v3(vn); plane_from_point_normal_v3(plane_cam, camera->loc, vn); zdepth = dist_squared_to_plane_v3(ob->obmat[3], plane_cam); } } cache_elem->zdepth = zdepth; (*gp_cache_used)++; return cache_array; }
[ "tGPencilObjectCache", "*", "gpencil_object_cache_add", "(", "tGPencilObjectCache", "*", "cache_array", ",", "Object", "*", "ob", ",", "int", "*", "gp_cache_size", ",", "int", "*", "gp_cache_used", ")", "{", "const", "DRWContextState", "*", "draw_ctx", "=", "DRW_context_state_get", "(", ")", ";", "tGPencilObjectCache", "*", "cache_elem", "=", "NULL", ";", "RegionView3D", "*", "rv3d", "=", "draw_ctx", "->", "rv3d", ";", "View3D", "*", "v3d", "=", "draw_ctx", "->", "v3d", ";", "tGPencilObjectCache", "*", "p", "=", "NULL", ";", "if", "(", "*", "gp_cache_used", "+", "1", ">", "*", "gp_cache_size", ")", "{", "if", "(", "(", "*", "gp_cache_size", "==", "0", ")", "||", "(", "cache_array", "==", "NULL", ")", ")", "{", "p", "=", "MEM_callocN", "(", "sizeof", "(", "struct", "tGPencilObjectCache", ")", "*", "GP_CACHE_BLOCK_SIZE", ",", "\"", "\"", ")", ";", "*", "gp_cache_size", "=", "GP_CACHE_BLOCK_SIZE", ";", "}", "else", "{", "*", "gp_cache_size", "+=", "GP_CACHE_BLOCK_SIZE", ";", "p", "=", "MEM_recallocN", "(", "cache_array", ",", "sizeof", "(", "struct", "tGPencilObjectCache", ")", "*", "*", "gp_cache_size", ")", ";", "}", "cache_array", "=", "p", ";", "}", "cache_elem", "=", "&", "cache_array", "[", "*", "gp_cache_used", "]", ";", "memset", "(", "cache_elem", ",", "0", ",", "sizeof", "(", "*", "cache_elem", ")", ")", ";", "cache_elem", "->", "ob", "=", "ob", ";", "cache_elem", "->", "gpd", "=", "(", "bGPdata", "*", ")", "ob", "->", "data", ";", "cache_elem", "->", "name", "=", "BKE_id_to_unique_string_key", "(", "&", "ob", "->", "id", ")", ";", "copy_v3_v3", "(", "cache_elem", "->", "loc", ",", "ob", "->", "obmat", "[", "3", "]", ")", ";", "copy_m4_m4", "(", "cache_elem", "->", "obmat", ",", "ob", "->", "obmat", ")", ";", "cache_elem", "->", "idx", "=", "*", "gp_cache_used", ";", "if", "(", "ob", "->", "base_flag", "&", "BASE_FROM_DUPLI", ")", "{", "bool", "has_original", "=", "gpencil_has_noninstanced_object", "(", "ob", ")", ";", "cache_elem", "->", "is_dup_ob", "=", "(", "has_original", ")", "?", "ob", "->", "base_flag", "&", "BASE_FROM_DUPLI", ":", "false", ";", "}", "else", "{", "cache_elem", "->", "is_dup_ob", "=", "false", ";", "}", "cache_elem", "->", "scale", "=", "mat4_to_scale", "(", "ob", "->", "obmat", ")", ";", "cache_elem", "->", "pixfactor", "=", "cache_elem", "->", "gpd", "->", "pixfactor", ";", "cache_elem", "->", "shader_fx", "=", "ob", "->", "shader_fx", ";", "if", "(", "ob", "->", "dt", "==", "OB_WIRE", ")", "{", "cache_elem", "->", "shading_type", "[", "0", "]", "=", "(", "int", ")", "OB_WIRE", ";", "}", "else", "{", "if", "(", "v3d", ")", "{", "cache_elem", "->", "shading_type", "[", "0", "]", "=", "(", "int", ")", "v3d", "->", "shading", ".", "type", ";", "}", "}", "cache_elem", "->", "tot_layers", "=", "0", ";", "int", "totgpl", "=", "BLI_listbase_count", "(", "&", "cache_elem", "->", "gpd", "->", "layers", ")", ";", "if", "(", "totgpl", ">", "0", ")", "{", "cache_elem", "->", "shgrp_array", "=", "MEM_callocN", "(", "sizeof", "(", "tGPencilObjectCache_shgrp", ")", "*", "totgpl", ",", "__func__", ")", ";", "}", "float", "zdepth", "=", "0.0", ";", "if", "(", "rv3d", ")", "{", "if", "(", "rv3d", "->", "is_persp", ")", "{", "zdepth", "=", "ED_view3d_calc_zfac", "(", "rv3d", ",", "ob", "->", "obmat", "[", "3", "]", ",", "NULL", ")", ";", "}", "else", "{", "zdepth", "=", "-", "dot_v3v3", "(", "rv3d", "->", "viewinv", "[", "2", "]", ",", "ob", "->", "obmat", "[", "3", "]", ")", ";", "}", "}", "else", "{", "float", "vn", "[", "3", "]", "=", "{", "0.0f", ",", "0.0f", ",", "-1.0f", "}", ";", "float", "plane_cam", "[", "4", "]", ";", "struct", "Object", "*", "camera", "=", "draw_ctx", "->", "scene", "->", "camera", ";", "if", "(", "camera", ")", "{", "mul_m4_v3", "(", "camera", "->", "obmat", ",", "vn", ")", ";", "normalize_v3", "(", "vn", ")", ";", "plane_from_point_normal_v3", "(", "plane_cam", ",", "camera", "->", "loc", ",", "vn", ")", ";", "zdepth", "=", "dist_squared_to_plane_v3", "(", "ob", "->", "obmat", "[", "3", "]", ",", "plane_cam", ")", ";", "}", "}", "cache_elem", "->", "zdepth", "=", "zdepth", ";", "(", "*", "gp_cache_used", ")", "++", ";", "return", "cache_array", ";", "}" ]
add a gpencil object to cache to defer drawing
[ "add", "a", "gpencil", "object", "to", "cache", "to", "defer", "drawing" ]
[ "/* By default a cache is created with one block with a predefined number of free slots,\n * if the size is not enough, the cache is reallocated adding a new block of free slots.\n * This is done in order to keep cache small. */", "/* zero out all pointers */", "/* object is duplicated (particle) */", "/* Check if the original object is not in the viewlayer\n * and cannot be managed as dupli. This is slower, but required to keep\n * the particle drawing FPS and display instanced objects in scene\n * without the original object */", "/* save FXs */", "/* save wire mode (object mode is always primary option) */", "/* shgrp array */", "/* calculate zdepth from point of view */", "/* In render mode, rv3d is not available, so use the distance to camera.\n * The real distance is not important, but the relative distance to the camera plane\n * in order to sort by z_depth of the objects\n */", "/* always face down */", "/* increase slots used in cache */" ]
[ { "param": "cache_array", "type": "tGPencilObjectCache" }, { "param": "ob", "type": "Object" }, { "param": "gp_cache_size", "type": "int" }, { "param": "gp_cache_used", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cache_array", "type": "tGPencilObjectCache", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gp_cache_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gp_cache_used", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f9df1342bf8e246044b66ef0cc2f777875777556
DemonRem/blender
source/blender/draw/engines/gpencil/gpencil_cache_utils.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gpencil_group_cache_add
GpencilBatchGroup
GpencilBatchGroup *gpencil_group_cache_add(GpencilBatchGroup *cache_array, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const short type, const bool onion, const int vertex_idx, int *grp_size, int *grp_used) { GpencilBatchGroup *cache_elem = NULL; GpencilBatchGroup *p = NULL; /* By default a cache is created with one block with a predefined number of free slots, * if the size is not enough, the cache is reallocated adding a new block of free slots. * This is done in order to keep cache small. */ if (*grp_used + 1 > *grp_size) { if ((*grp_size == 0) || (cache_array == NULL)) { p = MEM_callocN(sizeof(struct GpencilBatchGroup) * GPENCIL_GROUPS_BLOCK_SIZE, "GpencilBatchGroup"); *grp_size = GPENCIL_GROUPS_BLOCK_SIZE; } else { *grp_size += GPENCIL_GROUPS_BLOCK_SIZE; p = MEM_recallocN(cache_array, sizeof(struct GpencilBatchGroup) * *grp_size); } cache_array = p; } /* zero out all data */ cache_elem = &cache_array[*grp_used]; memset(cache_elem, 0, sizeof(*cache_elem)); cache_elem->gpl = gpl; cache_elem->gpf = gpf; cache_elem->gps = gps; cache_elem->type = type; cache_elem->onion = onion; cache_elem->vertex_idx = vertex_idx; /* increase slots used in cache */ (*grp_used)++; return cache_array; }
/* add a shading group to the cache to create later */
add a shading group to the cache to create later
[ "add", "a", "shading", "group", "to", "the", "cache", "to", "create", "later" ]
GpencilBatchGroup *gpencil_group_cache_add(GpencilBatchGroup *cache_array, bGPDlayer *gpl, bGPDframe *gpf, bGPDstroke *gps, const short type, const bool onion, const int vertex_idx, int *grp_size, int *grp_used) { GpencilBatchGroup *cache_elem = NULL; GpencilBatchGroup *p = NULL; if (*grp_used + 1 > *grp_size) { if ((*grp_size == 0) || (cache_array == NULL)) { p = MEM_callocN(sizeof(struct GpencilBatchGroup) * GPENCIL_GROUPS_BLOCK_SIZE, "GpencilBatchGroup"); *grp_size = GPENCIL_GROUPS_BLOCK_SIZE; } else { *grp_size += GPENCIL_GROUPS_BLOCK_SIZE; p = MEM_recallocN(cache_array, sizeof(struct GpencilBatchGroup) * *grp_size); } cache_array = p; } cache_elem = &cache_array[*grp_used]; memset(cache_elem, 0, sizeof(*cache_elem)); cache_elem->gpl = gpl; cache_elem->gpf = gpf; cache_elem->gps = gps; cache_elem->type = type; cache_elem->onion = onion; cache_elem->vertex_idx = vertex_idx; (*grp_used)++; return cache_array; }
[ "GpencilBatchGroup", "*", "gpencil_group_cache_add", "(", "GpencilBatchGroup", "*", "cache_array", ",", "bGPDlayer", "*", "gpl", ",", "bGPDframe", "*", "gpf", ",", "bGPDstroke", "*", "gps", ",", "const", "short", "type", ",", "const", "bool", "onion", ",", "const", "int", "vertex_idx", ",", "int", "*", "grp_size", ",", "int", "*", "grp_used", ")", "{", "GpencilBatchGroup", "*", "cache_elem", "=", "NULL", ";", "GpencilBatchGroup", "*", "p", "=", "NULL", ";", "if", "(", "*", "grp_used", "+", "1", ">", "*", "grp_size", ")", "{", "if", "(", "(", "*", "grp_size", "==", "0", ")", "||", "(", "cache_array", "==", "NULL", ")", ")", "{", "p", "=", "MEM_callocN", "(", "sizeof", "(", "struct", "GpencilBatchGroup", ")", "*", "GPENCIL_GROUPS_BLOCK_SIZE", ",", "\"", "\"", ")", ";", "*", "grp_size", "=", "GPENCIL_GROUPS_BLOCK_SIZE", ";", "}", "else", "{", "*", "grp_size", "+=", "GPENCIL_GROUPS_BLOCK_SIZE", ";", "p", "=", "MEM_recallocN", "(", "cache_array", ",", "sizeof", "(", "struct", "GpencilBatchGroup", ")", "*", "*", "grp_size", ")", ";", "}", "cache_array", "=", "p", ";", "}", "cache_elem", "=", "&", "cache_array", "[", "*", "grp_used", "]", ";", "memset", "(", "cache_elem", ",", "0", ",", "sizeof", "(", "*", "cache_elem", ")", ")", ";", "cache_elem", "->", "gpl", "=", "gpl", ";", "cache_elem", "->", "gpf", "=", "gpf", ";", "cache_elem", "->", "gps", "=", "gps", ";", "cache_elem", "->", "type", "=", "type", ";", "cache_elem", "->", "onion", "=", "onion", ";", "cache_elem", "->", "vertex_idx", "=", "vertex_idx", ";", "(", "*", "grp_used", ")", "++", ";", "return", "cache_array", ";", "}" ]
add a shading group to the cache to create later
[ "add", "a", "shading", "group", "to", "the", "cache", "to", "create", "later" ]
[ "/* By default a cache is created with one block with a predefined number of free slots,\n * if the size is not enough, the cache is reallocated adding a new block of free slots.\n * This is done in order to keep cache small. */", "/* zero out all data */", "/* increase slots used in cache */" ]
[ { "param": "cache_array", "type": "GpencilBatchGroup" }, { "param": "gpl", "type": "bGPDlayer" }, { "param": "gpf", "type": "bGPDframe" }, { "param": "gps", "type": "bGPDstroke" }, { "param": "type", "type": "short" }, { "param": "onion", "type": "bool" }, { "param": "vertex_idx", "type": "int" }, { "param": "grp_size", "type": "int" }, { "param": "grp_used", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cache_array", "type": "GpencilBatchGroup", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpl", "type": "bGPDlayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpf", "type": "bGPDframe", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "type", "type": "short", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "onion", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vertex_idx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "grp_size", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "grp_used", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
be265ed4bd5686247b4c3be6c98b9e06c19c43f9
DemonRem/blender
source/blender/editors/gpencil/gpencil_select.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
gp_stroke_do_circle_sel
bool
static bool gp_stroke_do_circle_sel(bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, GP_SpaceConversion *gsc, const int mx, const int my, const int radius, const bool select, rcti *rect, const float diff_mat[4][4], const int selectmode, const float scale) { const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); bGPDspoint *pt1 = NULL; bGPDspoint *pt2 = NULL; int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int i; bool changed = false; bGPDstroke *gps_active = (!is_multiedit) ? gps->runtime.gps_orig : gps; bGPDspoint *pt_active = NULL; if (gps->totpoints == 1) { bGPDspoint pt_temp; gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); gp_point_to_xy(gsc, gps, &pt_temp, &x0, &y0); /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) { /* only check if point is inside */ if (((x0 - mx) * (x0 - mx) + (y0 - my) * (y0 - my)) <= radius * radius) { /* change selection */ if (select) { gps_active->points->flag |= GP_SPOINT_SELECT; gps_active->flag |= GP_STROKE_SELECT; } else { gps_active->points->flag &= ~GP_SPOINT_SELECT; gps_active->flag &= ~GP_STROKE_SELECT; } return true; } } } else { /* Loop over the points in the stroke, checking for intersections * - an intersection means that we touched the stroke */ bool hit = false; for (i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ pt1 = gps->points + i; pt2 = gps->points + i + 1; bGPDspoint npt; gp_point_to_parent_space(pt1, diff_mat, &npt); gp_point_to_xy(gsc, gps, &npt, &x0, &y0); gp_point_to_parent_space(pt2, diff_mat, &npt); gp_point_to_xy(gsc, gps, &npt, &x1, &y1); /* check that point segment of the boundbox of the selection stroke */ if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) || ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) { float mval[2] = {(float)mx, (float)my}; float mvalo[2] = {(float)mx, (float)my}; /* dummy - this isn't used... */ /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant */ if (gp_stroke_inside_circle(mval, mvalo, radius, x0, y0, x1, y1)) { /* change selection of stroke, and then of both points * (as the last point otherwise wouldn't get selected * as we only do n-1 loops through). */ hit = true; if (select) { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { pt_active->flag |= GP_SPOINT_SELECT; } pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2; if (pt_active != NULL) { pt_active->flag |= GP_SPOINT_SELECT; } changed = true; } else { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { pt_active->flag &= ~GP_SPOINT_SELECT; } pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2; if (pt_active != NULL) { pt_active->flag &= ~GP_SPOINT_SELECT; } changed = true; } } } /* if stroke mode, don't check more points */ if ((hit) && (selectmode == GP_SELECTMODE_STROKE)) { break; } } /* if stroke mode expand selection */ if ((hit) && (selectmode == GP_SELECTMODE_STROKE)) { for (i = 0, pt1 = gps->points; i < gps->totpoints; i++, pt1++) { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { if (select) { pt_active->flag |= GP_SPOINT_SELECT; } else { pt_active->flag &= ~GP_SPOINT_SELECT; } } } } /* expand selection to segment */ pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if ((hit) && (selectmode == GP_SELECTMODE_SEGMENT) && (select) && (pt_active != NULL)) { float r_hita[3], r_hitb[3]; bool hit_select = (bool)(pt1->flag & GP_SPOINT_SELECT); ED_gpencil_select_stroke_segment( gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb); } /* Ensure that stroke selection is in sync with its points */ BKE_gpencil_stroke_sync_selection(gps_active); } return changed; }
/** * Helper to check if a given stroke is within the area. * * \note Code here is adapted (i.e. copied directly) * from gpencil_paint.c #gp_stroke_eraser_dostroke(). * It would be great to de-duplicate the logic here sometime, but that can wait. */
Helper to check if a given stroke is within the area. \note Code here is adapted from gpencil_paint.c #gp_stroke_eraser_dostroke(). It would be great to de-duplicate the logic here sometime, but that can wait.
[ "Helper", "to", "check", "if", "a", "given", "stroke", "is", "within", "the", "area", ".", "\\", "note", "Code", "here", "is", "adapted", "from", "gpencil_paint", ".", "c", "#gp_stroke_eraser_dostroke", "()", ".", "It", "would", "be", "great", "to", "de", "-", "duplicate", "the", "logic", "here", "sometime", "but", "that", "can", "wait", "." ]
static bool gp_stroke_do_circle_sel(bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, GP_SpaceConversion *gsc, const int mx, const int my, const int radius, const bool select, rcti *rect, const float diff_mat[4][4], const int selectmode, const float scale) { const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); bGPDspoint *pt1 = NULL; bGPDspoint *pt2 = NULL; int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int i; bool changed = false; bGPDstroke *gps_active = (!is_multiedit) ? gps->runtime.gps_orig : gps; bGPDspoint *pt_active = NULL; if (gps->totpoints == 1) { bGPDspoint pt_temp; gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); gp_point_to_xy(gsc, gps, &pt_temp, &x0, &y0); if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) { if (((x0 - mx) * (x0 - mx) + (y0 - my) * (y0 - my)) <= radius * radius) { if (select) { gps_active->points->flag |= GP_SPOINT_SELECT; gps_active->flag |= GP_STROKE_SELECT; } else { gps_active->points->flag &= ~GP_SPOINT_SELECT; gps_active->flag &= ~GP_STROKE_SELECT; } return true; } } } else { bool hit = false; for (i = 0; (i + 1) < gps->totpoints; i++) { pt1 = gps->points + i; pt2 = gps->points + i + 1; bGPDspoint npt; gp_point_to_parent_space(pt1, diff_mat, &npt); gp_point_to_xy(gsc, gps, &npt, &x0, &y0); gp_point_to_parent_space(pt2, diff_mat, &npt); gp_point_to_xy(gsc, gps, &npt, &x1, &y1); if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) || ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) { float mval[2] = {(float)mx, (float)my}; float mvalo[2] = {(float)mx, (float)my}; if (gp_stroke_inside_circle(mval, mvalo, radius, x0, y0, x1, y1)) { hit = true; if (select) { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { pt_active->flag |= GP_SPOINT_SELECT; } pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2; if (pt_active != NULL) { pt_active->flag |= GP_SPOINT_SELECT; } changed = true; } else { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { pt_active->flag &= ~GP_SPOINT_SELECT; } pt_active = (!is_multiedit) ? pt2->runtime.pt_orig : pt2; if (pt_active != NULL) { pt_active->flag &= ~GP_SPOINT_SELECT; } changed = true; } } } if ((hit) && (selectmode == GP_SELECTMODE_STROKE)) { break; } } if ((hit) && (selectmode == GP_SELECTMODE_STROKE)) { for (i = 0, pt1 = gps->points; i < gps->totpoints; i++, pt1++) { pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if (pt_active != NULL) { if (select) { pt_active->flag |= GP_SPOINT_SELECT; } else { pt_active->flag &= ~GP_SPOINT_SELECT; } } } } pt_active = (!is_multiedit) ? pt1->runtime.pt_orig : pt1; if ((hit) && (selectmode == GP_SELECTMODE_SEGMENT) && (select) && (pt_active != NULL)) { float r_hita[3], r_hitb[3]; bool hit_select = (bool)(pt1->flag & GP_SPOINT_SELECT); ED_gpencil_select_stroke_segment( gpl, gps_active, pt_active, hit_select, false, scale, r_hita, r_hitb); } BKE_gpencil_stroke_sync_selection(gps_active); } return changed; }
[ "static", "bool", "gp_stroke_do_circle_sel", "(", "bGPdata", "*", "gpd", ",", "bGPDlayer", "*", "gpl", ",", "bGPDstroke", "*", "gps", ",", "GP_SpaceConversion", "*", "gsc", ",", "const", "int", "mx", ",", "const", "int", "my", ",", "const", "int", "radius", ",", "const", "bool", "select", ",", "rcti", "*", "rect", ",", "const", "float", "diff_mat", "[", "4", "]", "[", "4", "]", ",", "const", "int", "selectmode", ",", "const", "float", "scale", ")", "{", "const", "bool", "is_multiedit", "=", "(", "bool", ")", "GPENCIL_MULTIEDIT_SESSIONS_ON", "(", "gpd", ")", ";", "bGPDspoint", "*", "pt1", "=", "NULL", ";", "bGPDspoint", "*", "pt2", "=", "NULL", ";", "int", "x0", "=", "0", ",", "y0", "=", "0", ",", "x1", "=", "0", ",", "y1", "=", "0", ";", "int", "i", ";", "bool", "changed", "=", "false", ";", "bGPDstroke", "*", "gps_active", "=", "(", "!", "is_multiedit", ")", "?", "gps", "->", "runtime", ".", "gps_orig", ":", "gps", ";", "bGPDspoint", "*", "pt_active", "=", "NULL", ";", "if", "(", "gps", "->", "totpoints", "==", "1", ")", "{", "bGPDspoint", "pt_temp", ";", "gp_point_to_parent_space", "(", "gps", "->", "points", ",", "diff_mat", ",", "&", "pt_temp", ")", ";", "gp_point_to_xy", "(", "gsc", ",", "gps", ",", "&", "pt_temp", ",", "&", "x0", ",", "&", "y0", ")", ";", "if", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "x0", ",", "y0", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "x0", ",", "y0", ")", ")", "{", "if", "(", "(", "(", "x0", "-", "mx", ")", "*", "(", "x0", "-", "mx", ")", "+", "(", "y0", "-", "my", ")", "*", "(", "y0", "-", "my", ")", ")", "<=", "radius", "*", "radius", ")", "{", "if", "(", "select", ")", "{", "gps_active", "->", "points", "->", "flag", "|=", "GP_SPOINT_SELECT", ";", "gps_active", "->", "flag", "|=", "GP_STROKE_SELECT", ";", "}", "else", "{", "gps_active", "->", "points", "->", "flag", "&=", "~", "GP_SPOINT_SELECT", ";", "gps_active", "->", "flag", "&=", "~", "GP_STROKE_SELECT", ";", "}", "return", "true", ";", "}", "}", "}", "else", "{", "bool", "hit", "=", "false", ";", "for", "(", "i", "=", "0", ";", "(", "i", "+", "1", ")", "<", "gps", "->", "totpoints", ";", "i", "++", ")", "{", "pt1", "=", "gps", "->", "points", "+", "i", ";", "pt2", "=", "gps", "->", "points", "+", "i", "+", "1", ";", "bGPDspoint", "npt", ";", "gp_point_to_parent_space", "(", "pt1", ",", "diff_mat", ",", "&", "npt", ")", ";", "gp_point_to_xy", "(", "gsc", ",", "gps", ",", "&", "npt", ",", "&", "x0", ",", "&", "y0", ")", ";", "gp_point_to_parent_space", "(", "pt2", ",", "diff_mat", ",", "&", "npt", ")", ";", "gp_point_to_xy", "(", "gsc", ",", "gps", ",", "&", "npt", ",", "&", "x1", ",", "&", "y1", ")", ";", "if", "(", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "x0", ",", "y0", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "x0", ",", "y0", ")", ")", "||", "(", "(", "!", "ELEM", "(", "V2D_IS_CLIPPED", ",", "x1", ",", "y1", ")", ")", "&&", "BLI_rcti_isect_pt", "(", "rect", ",", "x1", ",", "y1", ")", ")", ")", "{", "float", "mval", "[", "2", "]", "=", "{", "(", "float", ")", "mx", ",", "(", "float", ")", "my", "}", ";", "float", "mvalo", "[", "2", "]", "=", "{", "(", "float", ")", "mx", ",", "(", "float", ")", "my", "}", ";", "if", "(", "gp_stroke_inside_circle", "(", "mval", ",", "mvalo", ",", "radius", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ")", ")", "{", "hit", "=", "true", ";", "if", "(", "select", ")", "{", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt1", "->", "runtime", ".", "pt_orig", ":", "pt1", ";", "if", "(", "pt_active", "!=", "NULL", ")", "{", "pt_active", "->", "flag", "|=", "GP_SPOINT_SELECT", ";", "}", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt2", "->", "runtime", ".", "pt_orig", ":", "pt2", ";", "if", "(", "pt_active", "!=", "NULL", ")", "{", "pt_active", "->", "flag", "|=", "GP_SPOINT_SELECT", ";", "}", "changed", "=", "true", ";", "}", "else", "{", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt1", "->", "runtime", ".", "pt_orig", ":", "pt1", ";", "if", "(", "pt_active", "!=", "NULL", ")", "{", "pt_active", "->", "flag", "&=", "~", "GP_SPOINT_SELECT", ";", "}", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt2", "->", "runtime", ".", "pt_orig", ":", "pt2", ";", "if", "(", "pt_active", "!=", "NULL", ")", "{", "pt_active", "->", "flag", "&=", "~", "GP_SPOINT_SELECT", ";", "}", "changed", "=", "true", ";", "}", "}", "}", "if", "(", "(", "hit", ")", "&&", "(", "selectmode", "==", "GP_SELECTMODE_STROKE", ")", ")", "{", "break", ";", "}", "}", "if", "(", "(", "hit", ")", "&&", "(", "selectmode", "==", "GP_SELECTMODE_STROKE", ")", ")", "{", "for", "(", "i", "=", "0", ",", "pt1", "=", "gps", "->", "points", ";", "i", "<", "gps", "->", "totpoints", ";", "i", "++", ",", "pt1", "++", ")", "{", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt1", "->", "runtime", ".", "pt_orig", ":", "pt1", ";", "if", "(", "pt_active", "!=", "NULL", ")", "{", "if", "(", "select", ")", "{", "pt_active", "->", "flag", "|=", "GP_SPOINT_SELECT", ";", "}", "else", "{", "pt_active", "->", "flag", "&=", "~", "GP_SPOINT_SELECT", ";", "}", "}", "}", "}", "pt_active", "=", "(", "!", "is_multiedit", ")", "?", "pt1", "->", "runtime", ".", "pt_orig", ":", "pt1", ";", "if", "(", "(", "hit", ")", "&&", "(", "selectmode", "==", "GP_SELECTMODE_SEGMENT", ")", "&&", "(", "select", ")", "&&", "(", "pt_active", "!=", "NULL", ")", ")", "{", "float", "r_hita", "[", "3", "]", ",", "r_hitb", "[", "3", "]", ";", "bool", "hit_select", "=", "(", "bool", ")", "(", "pt1", "->", "flag", "&", "GP_SPOINT_SELECT", ")", ";", "ED_gpencil_select_stroke_segment", "(", "gpl", ",", "gps_active", ",", "pt_active", ",", "hit_select", ",", "false", ",", "scale", ",", "r_hita", ",", "r_hitb", ")", ";", "}", "BKE_gpencil_stroke_sync_selection", "(", "gps_active", ")", ";", "}", "return", "changed", ";", "}" ]
Helper to check if a given stroke is within the area.
[ "Helper", "to", "check", "if", "a", "given", "stroke", "is", "within", "the", "area", "." ]
[ "/* do boundbox check first */", "/* only check if point is inside */", "/* change selection */", "/* Loop over the points in the stroke, checking for intersections\n * - an intersection means that we touched the stroke\n */", "/* get points to work with */", "/* check that point segment of the boundbox of the selection stroke */", "/* dummy - this isn't used... */", "/* check if point segment of stroke had anything to do with\n * eraser region (either within stroke painted, or on its lines)\n * - this assumes that linewidth is irrelevant\n */", "/* change selection of stroke, and then of both points\n * (as the last point otherwise wouldn't get selected\n * as we only do n-1 loops through).\n */", "/* if stroke mode, don't check more points */", "/* if stroke mode expand selection */", "/* expand selection to segment */", "/* Ensure that stroke selection is in sync with its points */" ]
[ { "param": "gpd", "type": "bGPdata" }, { "param": "gpl", "type": "bGPDlayer" }, { "param": "gps", "type": "bGPDstroke" }, { "param": "gsc", "type": "GP_SpaceConversion" }, { "param": "mx", "type": "int" }, { "param": "my", "type": "int" }, { "param": "radius", "type": "int" }, { "param": "select", "type": "bool" }, { "param": "rect", "type": "rcti" }, { "param": "diff_mat", "type": "float" }, { "param": "selectmode", "type": "int" }, { "param": "scale", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gpd", "type": "bGPdata", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gpl", "type": "bGPDlayer", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gps", "type": "bGPDstroke", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "gsc", "type": "GP_SpaceConversion", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "mx", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "my", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "radius", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "select", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rect", "type": "rcti", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "diff_mat", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "selectmode", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "scale", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0fe7c6637e4f6bbc7ce6ead6e3aab722e8f8547
DemonRem/blender
source/blender/draw/engines/eevee/eevee_materials.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
add_standard_uniforms
void
static void add_standard_uniforms(DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int *ssr_id, float *refract_depth, bool use_diffuse, bool use_glossy, bool use_refract, bool use_ssrefraction, bool use_alpha_blend) { LightCache *lcache = vedata->stl->g_data->light_cache; EEVEE_EffectsInfo *effects = vedata->stl->effects; DRW_shgroup_uniform_block(shgrp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo); DRW_shgroup_uniform_block(shgrp, "planar_block", sldata->planar_ubo); DRW_shgroup_uniform_block(shgrp, "light_block", sldata->light_ubo); DRW_shgroup_uniform_block(shgrp, "shadow_block", sldata->shadow_ubo); DRW_shgroup_uniform_block(shgrp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_int_copy(shgrp, "outputSssId", 1); if (use_diffuse || use_glossy || use_refract) { DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex); DRW_shgroup_uniform_texture_ref(shgrp, "shadowCubeTexture", &sldata->shadow_cube_pool); DRW_shgroup_uniform_texture_ref(shgrp, "shadowCascadeTexture", &sldata->shadow_cascade_pool); DRW_shgroup_uniform_texture_ref(shgrp, "maxzBuffer", &vedata->txl->maxzbuffer); } if ((use_diffuse || use_glossy) && !use_ssrefraction) { DRW_shgroup_uniform_texture_ref(shgrp, "horizonBuffer", &effects->gtao_horizons); } if (use_diffuse) { DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex); } if (use_glossy || use_refract) { DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &lcache->cube_tx.tex); } if (use_glossy) { DRW_shgroup_uniform_texture_ref(shgrp, "probePlanars", &vedata->txl->planar_pool); DRW_shgroup_uniform_int_copy(shgrp, "outputSsrId", ssr_id ? *ssr_id : 0); } if (use_refract) { DRW_shgroup_uniform_float_copy( shgrp, "refractionDepth", (refract_depth) ? *refract_depth : 0.0); if (use_ssrefraction) { DRW_shgroup_uniform_texture_ref(shgrp, "colorBuffer", &vedata->txl->refract_color); } } if (use_alpha_blend) { DRW_shgroup_uniform_texture_ref(shgrp, "inScattering", &effects->volume_scatter); DRW_shgroup_uniform_texture_ref(shgrp, "inTransmittance", &effects->volume_transmit); } }
/** * ssr_id can be null to disable ssr contribution. */
ssr_id can be null to disable ssr contribution.
[ "ssr_id", "can", "be", "null", "to", "disable", "ssr", "contribution", "." ]
static void add_standard_uniforms(DRWShadingGroup *shgrp, EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, int *ssr_id, float *refract_depth, bool use_diffuse, bool use_glossy, bool use_refract, bool use_ssrefraction, bool use_alpha_blend) { LightCache *lcache = vedata->stl->g_data->light_cache; EEVEE_EffectsInfo *effects = vedata->stl->effects; DRW_shgroup_uniform_block(shgrp, "probe_block", sldata->probe_ubo); DRW_shgroup_uniform_block(shgrp, "grid_block", sldata->grid_ubo); DRW_shgroup_uniform_block(shgrp, "planar_block", sldata->planar_ubo); DRW_shgroup_uniform_block(shgrp, "light_block", sldata->light_ubo); DRW_shgroup_uniform_block(shgrp, "shadow_block", sldata->shadow_ubo); DRW_shgroup_uniform_block(shgrp, "common_block", sldata->common_ubo); DRW_shgroup_uniform_int_copy(shgrp, "outputSssId", 1); if (use_diffuse || use_glossy || use_refract) { DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex); DRW_shgroup_uniform_texture_ref(shgrp, "shadowCubeTexture", &sldata->shadow_cube_pool); DRW_shgroup_uniform_texture_ref(shgrp, "shadowCascadeTexture", &sldata->shadow_cascade_pool); DRW_shgroup_uniform_texture_ref(shgrp, "maxzBuffer", &vedata->txl->maxzbuffer); } if ((use_diffuse || use_glossy) && !use_ssrefraction) { DRW_shgroup_uniform_texture_ref(shgrp, "horizonBuffer", &effects->gtao_horizons); } if (use_diffuse) { DRW_shgroup_uniform_texture_ref(shgrp, "irradianceGrid", &lcache->grid_tx.tex); } if (use_glossy || use_refract) { DRW_shgroup_uniform_texture_ref(shgrp, "probeCubes", &lcache->cube_tx.tex); } if (use_glossy) { DRW_shgroup_uniform_texture_ref(shgrp, "probePlanars", &vedata->txl->planar_pool); DRW_shgroup_uniform_int_copy(shgrp, "outputSsrId", ssr_id ? *ssr_id : 0); } if (use_refract) { DRW_shgroup_uniform_float_copy( shgrp, "refractionDepth", (refract_depth) ? *refract_depth : 0.0); if (use_ssrefraction) { DRW_shgroup_uniform_texture_ref(shgrp, "colorBuffer", &vedata->txl->refract_color); } } if (use_alpha_blend) { DRW_shgroup_uniform_texture_ref(shgrp, "inScattering", &effects->volume_scatter); DRW_shgroup_uniform_texture_ref(shgrp, "inTransmittance", &effects->volume_transmit); } }
[ "static", "void", "add_standard_uniforms", "(", "DRWShadingGroup", "*", "shgrp", ",", "EEVEE_ViewLayerData", "*", "sldata", ",", "EEVEE_Data", "*", "vedata", ",", "int", "*", "ssr_id", ",", "float", "*", "refract_depth", ",", "bool", "use_diffuse", ",", "bool", "use_glossy", ",", "bool", "use_refract", ",", "bool", "use_ssrefraction", ",", "bool", "use_alpha_blend", ")", "{", "LightCache", "*", "lcache", "=", "vedata", "->", "stl", "->", "g_data", "->", "light_cache", ";", "EEVEE_EffectsInfo", "*", "effects", "=", "vedata", "->", "stl", "->", "effects", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "probe_ubo", ")", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "grid_ubo", ")", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "planar_ubo", ")", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "light_ubo", ")", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "shadow_ubo", ")", ";", "DRW_shgroup_uniform_block", "(", "shgrp", ",", "\"", "\"", ",", "sldata", "->", "common_ubo", ")", ";", "DRW_shgroup_uniform_int_copy", "(", "shgrp", ",", "\"", "\"", ",", "1", ")", ";", "if", "(", "use_diffuse", "||", "use_glossy", "||", "use_refract", ")", "{", "DRW_shgroup_uniform_texture", "(", "shgrp", ",", "\"", "\"", ",", "e_data", ".", "util_tex", ")", ";", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "sldata", "->", "shadow_cube_pool", ")", ";", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "sldata", "->", "shadow_cascade_pool", ")", ";", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "vedata", "->", "txl", "->", "maxzbuffer", ")", ";", "}", "if", "(", "(", "use_diffuse", "||", "use_glossy", ")", "&&", "!", "use_ssrefraction", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "effects", "->", "gtao_horizons", ")", ";", "}", "if", "(", "use_diffuse", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "lcache", "->", "grid_tx", ".", "tex", ")", ";", "}", "if", "(", "use_glossy", "||", "use_refract", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "lcache", "->", "cube_tx", ".", "tex", ")", ";", "}", "if", "(", "use_glossy", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "vedata", "->", "txl", "->", "planar_pool", ")", ";", "DRW_shgroup_uniform_int_copy", "(", "shgrp", ",", "\"", "\"", ",", "ssr_id", "?", "*", "ssr_id", ":", "0", ")", ";", "}", "if", "(", "use_refract", ")", "{", "DRW_shgroup_uniform_float_copy", "(", "shgrp", ",", "\"", "\"", ",", "(", "refract_depth", ")", "?", "*", "refract_depth", ":", "0.0", ")", ";", "if", "(", "use_ssrefraction", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "vedata", "->", "txl", "->", "refract_color", ")", ";", "}", "}", "if", "(", "use_alpha_blend", ")", "{", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "effects", "->", "volume_scatter", ")", ";", "DRW_shgroup_uniform_texture_ref", "(", "shgrp", ",", "\"", "\"", ",", "&", "effects", "->", "volume_transmit", ")", ";", "}", "}" ]
ssr_id can be null to disable ssr contribution.
[ "ssr_id", "can", "be", "null", "to", "disable", "ssr", "contribution", "." ]
[]
[ { "param": "shgrp", "type": "DRWShadingGroup" }, { "param": "sldata", "type": "EEVEE_ViewLayerData" }, { "param": "vedata", "type": "EEVEE_Data" }, { "param": "ssr_id", "type": "int" }, { "param": "refract_depth", "type": "float" }, { "param": "use_diffuse", "type": "bool" }, { "param": "use_glossy", "type": "bool" }, { "param": "use_refract", "type": "bool" }, { "param": "use_ssrefraction", "type": "bool" }, { "param": "use_alpha_blend", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "shgrp", "type": "DRWShadingGroup", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sldata", "type": "EEVEE_ViewLayerData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vedata", "type": "EEVEE_Data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ssr_id", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "refract_depth", "type": "float", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_diffuse", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_glossy", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_refract", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_ssrefraction", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_alpha_blend", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0fe7c6637e4f6bbc7ce6ead6e3aab722e8f8547
DemonRem/blender
source/blender/draw/engines/eevee/eevee_materials.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
EEVEE_default_shading_group_create
null
static struct DRWShadingGroup *EEVEE_default_shading_group_create(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass, bool is_hair, bool use_blend, bool use_ssr) { static int ssr_id; ssr_id = (use_ssr) ? 1 : -1; int options = VAR_MAT_MESH; SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR); SET_FLAG_FROM_TEST(options, use_blend, VAR_MAT_BLEND); if (e_data.default_lit[options] == NULL) { create_default_shader(options); } DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], pass); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, use_blend); return shgrp; }
/** * Create a default shading group inside the given pass. */
Create a default shading group inside the given pass.
[ "Create", "a", "default", "shading", "group", "inside", "the", "given", "pass", "." ]
static struct DRWShadingGroup *EEVEE_default_shading_group_create(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWPass *pass, bool is_hair, bool use_blend, bool use_ssr) { static int ssr_id; ssr_id = (use_ssr) ? 1 : -1; int options = VAR_MAT_MESH; SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR); SET_FLAG_FROM_TEST(options, use_blend, VAR_MAT_BLEND); if (e_data.default_lit[options] == NULL) { create_default_shader(options); } DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], pass); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, use_blend); return shgrp; }
[ "static", "struct", "DRWShadingGroup", "*", "EEVEE_default_shading_group_create", "(", "EEVEE_ViewLayerData", "*", "sldata", ",", "EEVEE_Data", "*", "vedata", ",", "DRWPass", "*", "pass", ",", "bool", "is_hair", ",", "bool", "use_blend", ",", "bool", "use_ssr", ")", "{", "static", "int", "ssr_id", ";", "ssr_id", "=", "(", "use_ssr", ")", "?", "1", ":", "-1", ";", "int", "options", "=", "VAR_MAT_MESH", ";", "SET_FLAG_FROM_TEST", "(", "options", ",", "is_hair", ",", "VAR_MAT_HAIR", ")", ";", "SET_FLAG_FROM_TEST", "(", "options", ",", "use_blend", ",", "VAR_MAT_BLEND", ")", ";", "if", "(", "e_data", ".", "default_lit", "[", "options", "]", "==", "NULL", ")", "{", "create_default_shader", "(", "options", ")", ";", "}", "DRWShadingGroup", "*", "shgrp", "=", "DRW_shgroup_create", "(", "e_data", ".", "default_lit", "[", "options", "]", ",", "pass", ")", ";", "add_standard_uniforms", "(", "shgrp", ",", "sldata", ",", "vedata", ",", "&", "ssr_id", ",", "NULL", ",", "true", ",", "true", ",", "false", ",", "false", ",", "use_blend", ")", ";", "return", "shgrp", ";", "}" ]
Create a default shading group inside the given pass.
[ "Create", "a", "default", "shading", "group", "inside", "the", "given", "pass", "." ]
[]
[ { "param": "sldata", "type": "EEVEE_ViewLayerData" }, { "param": "vedata", "type": "EEVEE_Data" }, { "param": "pass", "type": "DRWPass" }, { "param": "is_hair", "type": "bool" }, { "param": "use_blend", "type": "bool" }, { "param": "use_ssr", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sldata", "type": "EEVEE_ViewLayerData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vedata", "type": "EEVEE_Data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pass", "type": "DRWPass", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_hair", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_blend", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_ssr", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d0fe7c6637e4f6bbc7ce6ead6e3aab722e8f8547
DemonRem/blender
source/blender/draw/engines/eevee/eevee_materials.c
[ "Naumen", "Condor-1.1", "MS-PL" ]
C
EEVEE_default_shading_group_get
null
static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob, ParticleSystem *psys, ModifierData *md, bool is_hair, bool holdout, bool use_ssr) { static int ssr_id; ssr_id = (use_ssr) ? 1 : -1; int options = VAR_MAT_MESH; EEVEE_PassList *psl = vedata->psl; BLI_assert(!is_hair || (ob && psys && md)); SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR); SET_FLAG_FROM_TEST(options, holdout, VAR_MAT_HOLDOUT); if (e_data.default_lit[options] == NULL) { create_default_shader(options); } if (psl->default_pass[options] == NULL) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES; DRW_PASS_CREATE(psl->default_pass[options], state); /* XXX / WATCH: This creates non persistent binds for the ubos and textures. * But it's currently OK because the following shgroups does not add any bind. * EDIT: THIS IS NOT THE CASE FOR HAIRS !!! DUMMY!!! */ if (!is_hair) { DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->default_pass[options]); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false); } } if (is_hair) { DRWShadingGroup *shgrp = DRW_shgroup_hair_create( ob, psys, md, vedata->psl->default_pass[options], e_data.default_lit[options]); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false); return shgrp; } else { return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]); } }
/** * Create a default shading group inside the default pass without standard uniforms. */
Create a default shading group inside the default pass without standard uniforms.
[ "Create", "a", "default", "shading", "group", "inside", "the", "default", "pass", "without", "standard", "uniforms", "." ]
static struct DRWShadingGroup *EEVEE_default_shading_group_get(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, Object *ob, ParticleSystem *psys, ModifierData *md, bool is_hair, bool holdout, bool use_ssr) { static int ssr_id; ssr_id = (use_ssr) ? 1 : -1; int options = VAR_MAT_MESH; EEVEE_PassList *psl = vedata->psl; BLI_assert(!is_hair || (ob && psys && md)); SET_FLAG_FROM_TEST(options, is_hair, VAR_MAT_HAIR); SET_FLAG_FROM_TEST(options, holdout, VAR_MAT_HOLDOUT); if (e_data.default_lit[options] == NULL) { create_default_shader(options); } if (psl->default_pass[options] == NULL) { DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_CLIP_PLANES; DRW_PASS_CREATE(psl->default_pass[options], state); if (!is_hair) { DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.default_lit[options], psl->default_pass[options]); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false); } } if (is_hair) { DRWShadingGroup *shgrp = DRW_shgroup_hair_create( ob, psys, md, vedata->psl->default_pass[options], e_data.default_lit[options]); add_standard_uniforms(shgrp, sldata, vedata, &ssr_id, NULL, true, true, false, false, false); return shgrp; } else { return DRW_shgroup_create(e_data.default_lit[options], vedata->psl->default_pass[options]); } }
[ "static", "struct", "DRWShadingGroup", "*", "EEVEE_default_shading_group_get", "(", "EEVEE_ViewLayerData", "*", "sldata", ",", "EEVEE_Data", "*", "vedata", ",", "Object", "*", "ob", ",", "ParticleSystem", "*", "psys", ",", "ModifierData", "*", "md", ",", "bool", "is_hair", ",", "bool", "holdout", ",", "bool", "use_ssr", ")", "{", "static", "int", "ssr_id", ";", "ssr_id", "=", "(", "use_ssr", ")", "?", "1", ":", "-1", ";", "int", "options", "=", "VAR_MAT_MESH", ";", "EEVEE_PassList", "*", "psl", "=", "vedata", "->", "psl", ";", "BLI_assert", "(", "!", "is_hair", "||", "(", "ob", "&&", "psys", "&&", "md", ")", ")", ";", "SET_FLAG_FROM_TEST", "(", "options", ",", "is_hair", ",", "VAR_MAT_HAIR", ")", ";", "SET_FLAG_FROM_TEST", "(", "options", ",", "holdout", ",", "VAR_MAT_HOLDOUT", ")", ";", "if", "(", "e_data", ".", "default_lit", "[", "options", "]", "==", "NULL", ")", "{", "create_default_shader", "(", "options", ")", ";", "}", "if", "(", "psl", "->", "default_pass", "[", "options", "]", "==", "NULL", ")", "{", "DRWState", "state", "=", "DRW_STATE_WRITE_COLOR", "|", "DRW_STATE_DEPTH_EQUAL", "|", "DRW_STATE_CLIP_PLANES", ";", "DRW_PASS_CREATE", "(", "psl", "->", "default_pass", "[", "options", "]", ",", "state", ")", ";", "if", "(", "!", "is_hair", ")", "{", "DRWShadingGroup", "*", "shgrp", "=", "DRW_shgroup_create", "(", "e_data", ".", "default_lit", "[", "options", "]", ",", "psl", "->", "default_pass", "[", "options", "]", ")", ";", "add_standard_uniforms", "(", "shgrp", ",", "sldata", ",", "vedata", ",", "&", "ssr_id", ",", "NULL", ",", "true", ",", "true", ",", "false", ",", "false", ",", "false", ")", ";", "}", "}", "if", "(", "is_hair", ")", "{", "DRWShadingGroup", "*", "shgrp", "=", "DRW_shgroup_hair_create", "(", "ob", ",", "psys", ",", "md", ",", "vedata", "->", "psl", "->", "default_pass", "[", "options", "]", ",", "e_data", ".", "default_lit", "[", "options", "]", ")", ";", "add_standard_uniforms", "(", "shgrp", ",", "sldata", ",", "vedata", ",", "&", "ssr_id", ",", "NULL", ",", "true", ",", "true", ",", "false", ",", "false", ",", "false", ")", ";", "return", "shgrp", ";", "}", "else", "{", "return", "DRW_shgroup_create", "(", "e_data", ".", "default_lit", "[", "options", "]", ",", "vedata", "->", "psl", "->", "default_pass", "[", "options", "]", ")", ";", "}", "}" ]
Create a default shading group inside the default pass without standard uniforms.
[ "Create", "a", "default", "shading", "group", "inside", "the", "default", "pass", "without", "standard", "uniforms", "." ]
[ "/* XXX / WATCH: This creates non persistent binds for the ubos and textures.\n * But it's currently OK because the following shgroups does not add any bind.\n * EDIT: THIS IS NOT THE CASE FOR HAIRS !!! DUMMY!!! */" ]
[ { "param": "sldata", "type": "EEVEE_ViewLayerData" }, { "param": "vedata", "type": "EEVEE_Data" }, { "param": "ob", "type": "Object" }, { "param": "psys", "type": "ParticleSystem" }, { "param": "md", "type": "ModifierData" }, { "param": "is_hair", "type": "bool" }, { "param": "holdout", "type": "bool" }, { "param": "use_ssr", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sldata", "type": "EEVEE_ViewLayerData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vedata", "type": "EEVEE_Data", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ob", "type": "Object", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "psys", "type": "ParticleSystem", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "md", "type": "ModifierData", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "is_hair", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "holdout", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_ssr", "type": "bool", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f648b05a79683affc79caea16c0a19b048fbff58
TedPap/opsys
bios_example5.c
[ "MIT" ]
C
read_serial
ssize_t
ssize_t read_serial(void *cookie, char *buf, size_t size) { uint core = cpu_core_id; ssize_t ret = 0; char c = '\0'; while(size>0 && c!='\n') { /* get a character */ if(! bios_read_serial(core, &c)) { cpu_disable_interrupts(); /* Wait in a busy loop, polling the driver. */ while(! bios_read_serial(core, &c)) ; cpu_enable_interrupts(); } *buf = c; buf++; ret++; size--; } return ret; }
/* A simple program to demonstrate using serial devices. To run this program, you must execute two terminals in two different windows first. Otherwise, the program will block. */
A simple program to demonstrate using serial devices. To run this program, you must execute two terminals in two different windows first. Otherwise, the program will block.
[ "A", "simple", "program", "to", "demonstrate", "using", "serial", "devices", ".", "To", "run", "this", "program", "you", "must", "execute", "two", "terminals", "in", "two", "different", "windows", "first", ".", "Otherwise", "the", "program", "will", "block", "." ]
ssize_t read_serial(void *cookie, char *buf, size_t size) { uint core = cpu_core_id; ssize_t ret = 0; char c = '\0'; while(size>0 && c!='\n') { if(! bios_read_serial(core, &c)) { cpu_disable_interrupts(); while(! bios_read_serial(core, &c)) ; cpu_enable_interrupts(); } *buf = c; buf++; ret++; size--; } return ret; }
[ "ssize_t", "read_serial", "(", "void", "*", "cookie", ",", "char", "*", "buf", ",", "size_t", "size", ")", "{", "uint", "core", "=", "cpu_core_id", ";", "ssize_t", "ret", "=", "0", ";", "char", "c", "=", "'", "\\0", "'", ";", "while", "(", "size", ">", "0", "&&", "c", "!=", "'", "\\n", "'", ")", "{", "if", "(", "!", "bios_read_serial", "(", "core", ",", "&", "c", ")", ")", "{", "cpu_disable_interrupts", "(", ")", ";", "while", "(", "!", "bios_read_serial", "(", "core", ",", "&", "c", ")", ")", ";", "cpu_enable_interrupts", "(", ")", ";", "}", "*", "buf", "=", "c", ";", "buf", "++", ";", "ret", "++", ";", "size", "--", ";", "}", "return", "ret", ";", "}" ]
A simple program to demonstrate using serial devices.
[ "A", "simple", "program", "to", "demonstrate", "using", "serial", "devices", "." ]
[ "/* get a character */", "/*\n\t\t\t\tWait in a busy loop, polling the driver.\n\t\t\t */" ]
[ { "param": "cookie", "type": "void" }, { "param": "buf", "type": "char" }, { "param": "size", "type": "size_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cookie", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "size_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
53357cd4fa07a373a8575f552d17e2da73307f37
TedPap/opsys
kernel_init.c
[ "MIT" ]
C
boot_tinyos_kernel
void
void boot_tinyos_kernel() { if(cpu_core_id==0) { /* Initialize the kenrel data structures */ initialize_processes(); initialize_devices(); initialize_files(); initialize_scheduler(); /* The boot task is executed normally! */ if(Exec(boot_rec.init_task, boot_rec.argl, boot_rec.args)!=1) FATAL("The init process does not have PID==1"); } cpu_core_barrier_sync(); #ifndef NVALGRIND VALGRIND_PRINTF_BACKTRACE("TINYOS: Entering scheduler for core %d\n",cpu_core_id); #endif run_scheduler(); if(cpu_core_id==0) { /* Here, we could add cleanup after the scheduler has ended. */ } }
/* Per-core boot function for tinyos */
Per-core boot function for tinyos
[ "Per", "-", "core", "boot", "function", "for", "tinyos" ]
void boot_tinyos_kernel() { if(cpu_core_id==0) { initialize_processes(); initialize_devices(); initialize_files(); initialize_scheduler(); if(Exec(boot_rec.init_task, boot_rec.argl, boot_rec.args)!=1) FATAL("The init process does not have PID==1"); } cpu_core_barrier_sync(); #ifndef NVALGRIND VALGRIND_PRINTF_BACKTRACE("TINYOS: Entering scheduler for core %d\n",cpu_core_id); #endif run_scheduler(); if(cpu_core_id==0) { } }
[ "void", "boot_tinyos_kernel", "(", ")", "{", "if", "(", "cpu_core_id", "==", "0", ")", "{", "initialize_processes", "(", ")", ";", "initialize_devices", "(", ")", ";", "initialize_files", "(", ")", ";", "initialize_scheduler", "(", ")", ";", "if", "(", "Exec", "(", "boot_rec", ".", "init_task", ",", "boot_rec", ".", "argl", ",", "boot_rec", ".", "args", ")", "!=", "1", ")", "FATAL", "(", "\"", "\"", ")", ";", "}", "cpu_core_barrier_sync", "(", ")", ";", "#ifndef", "NVALGRIND", "VALGRIND_PRINTF_BACKTRACE", "(", "\"", "\\n", "\"", ",", "cpu_core_id", ")", ";", "#endif", "run_scheduler", "(", ")", ";", "if", "(", "cpu_core_id", "==", "0", ")", "{", "}", "}" ]
Per-core boot function for tinyos
[ "Per", "-", "core", "boot", "function", "for", "tinyos" ]
[ "/* Initialize the kenrel data structures */", "/* The boot task is executed normally! */", "/* Here, we could add cleanup after the scheduler has ended. */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
socket_read
int
int socket_read(void* ptr, char *buf, unsigned int size) { SCB* temp = (SCB*) ptr; FCB* fcb; int ret; if (temp->type == PEER){ fcb = get_fcb(temp->peer.fid_receive); ret = fcb->streamfunc->Read(fcb->streamobj, buf, size); return ret; } else{ return 0; } return 0; }
/** Call to the read pipe's Read fileop. */
Call to the read pipe's Read fileop.
[ "Call", "to", "the", "read", "pipe", "'", "s", "Read", "fileop", "." ]
int socket_read(void* ptr, char *buf, unsigned int size) { SCB* temp = (SCB*) ptr; FCB* fcb; int ret; if (temp->type == PEER){ fcb = get_fcb(temp->peer.fid_receive); ret = fcb->streamfunc->Read(fcb->streamobj, buf, size); return ret; } else{ return 0; } return 0; }
[ "int", "socket_read", "(", "void", "*", "ptr", ",", "char", "*", "buf", ",", "unsigned", "int", "size", ")", "{", "SCB", "*", "temp", "=", "(", "SCB", "*", ")", "ptr", ";", "FCB", "*", "fcb", ";", "int", "ret", ";", "if", "(", "temp", "->", "type", "==", "PEER", ")", "{", "fcb", "=", "get_fcb", "(", "temp", "->", "peer", ".", "fid_receive", ")", ";", "ret", "=", "fcb", "->", "streamfunc", "->", "Read", "(", "fcb", "->", "streamobj", ",", "buf", ",", "size", ")", ";", "return", "ret", ";", "}", "else", "{", "return", "0", ";", "}", "return", "0", ";", "}" ]
Call to the read pipe's Read fileop.
[ "Call", "to", "the", "read", "pipe", "'", "s", "Read", "fileop", "." ]
[]
[ { "param": "ptr", "type": "void" }, { "param": "buf", "type": "char" }, { "param": "size", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
socket_write
int
int socket_write(void* ptr, const char* buf, unsigned int size) { SCB* temp = (SCB*) ptr; FCB* fcb; int ret; if (temp->type == PEER){ fcb = get_fcb(temp->peer.fid_send); ret = fcb->streamfunc->Write(fcb->streamobj, buf, size); return ret; } else{ return 0; } return 0; }
/** Call to the write pipe's Write fileop. */
Call to the write pipe's Write fileop.
[ "Call", "to", "the", "write", "pipe", "'", "s", "Write", "fileop", "." ]
int socket_write(void* ptr, const char* buf, unsigned int size) { SCB* temp = (SCB*) ptr; FCB* fcb; int ret; if (temp->type == PEER){ fcb = get_fcb(temp->peer.fid_send); ret = fcb->streamfunc->Write(fcb->streamobj, buf, size); return ret; } else{ return 0; } return 0; }
[ "int", "socket_write", "(", "void", "*", "ptr", ",", "const", "char", "*", "buf", ",", "unsigned", "int", "size", ")", "{", "SCB", "*", "temp", "=", "(", "SCB", "*", ")", "ptr", ";", "FCB", "*", "fcb", ";", "int", "ret", ";", "if", "(", "temp", "->", "type", "==", "PEER", ")", "{", "fcb", "=", "get_fcb", "(", "temp", "->", "peer", ".", "fid_send", ")", ";", "ret", "=", "fcb", "->", "streamfunc", "->", "Write", "(", "fcb", "->", "streamobj", ",", "buf", ",", "size", ")", ";", "return", "ret", ";", "}", "else", "{", "return", "0", ";", "}", "return", "0", ";", "}" ]
Call to the write pipe's Write fileop.
[ "Call", "to", "the", "write", "pipe", "'", "s", "Write", "fileop", "." ]
[]
[ { "param": "ptr", "type": "void" }, { "param": "buf", "type": "char" }, { "param": "size", "type": "unsigned int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "buf", "type": "char", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "size", "type": "unsigned int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
socket_close
int
int socket_close(void* ptr) { SCB* temp = (SCB*) ptr; temp->refcount--; if (temp->refcount == 0) OccupiedPorts[temp->portnum] = false; free(ptr); return 0; }
/** Free the alocated space of the socket. */
Free the alocated space of the socket.
[ "Free", "the", "alocated", "space", "of", "the", "socket", "." ]
int socket_close(void* ptr) { SCB* temp = (SCB*) ptr; temp->refcount--; if (temp->refcount == 0) OccupiedPorts[temp->portnum] = false; free(ptr); return 0; }
[ "int", "socket_close", "(", "void", "*", "ptr", ")", "{", "SCB", "*", "temp", "=", "(", "SCB", "*", ")", "ptr", ";", "temp", "->", "refcount", "--", ";", "if", "(", "temp", "->", "refcount", "==", "0", ")", "OccupiedPorts", "[", "temp", "->", "portnum", "]", "=", "false", ";", "free", "(", "ptr", ")", ";", "return", "0", ";", "}" ]
Free the alocated space of the socket.
[ "Free", "the", "alocated", "space", "of", "the", "socket", "." ]
[]
[ { "param": "ptr", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "ptr", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
Socket
Fid_t
Fid_t Socket(port_t port) { bool err = false; Fid_t fid; FCB* fcb; SCB* scb; Mutex_Lock(& kernel_mutex); /** Error check. */ if (port < NOPORT || port > MAX_PORT) { err = true; } else { if (FCB_reserve(1, &fid, &fcb) == 1) { /** Check for enough fid's */ scb = (SCB*) socket_init(); scb->refcount = 1; scb->type = UNBOUND; scb->portnum = port; fcb->streamobj = scb; fcb->streamfunc = &socket_fops; } else { err = true; } } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return fid; case true: return NOFILE; } return NOFILE; }
/** Create and initialize an UNBOUND socket control block. */
Create and initialize an UNBOUND socket control block.
[ "Create", "and", "initialize", "an", "UNBOUND", "socket", "control", "block", "." ]
Fid_t Socket(port_t port) { bool err = false; Fid_t fid; FCB* fcb; SCB* scb; Mutex_Lock(& kernel_mutex); if (port < NOPORT || port > MAX_PORT) { err = true; } else { if (FCB_reserve(1, &fid, &fcb) == 1) { scb = (SCB*) socket_init(); scb->refcount = 1; scb->type = UNBOUND; scb->portnum = port; fcb->streamobj = scb; fcb->streamfunc = &socket_fops; } else { err = true; } } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return fid; case true: return NOFILE; } return NOFILE; }
[ "Fid_t", "Socket", "(", "port_t", "port", ")", "{", "bool", "err", "=", "false", ";", "Fid_t", "fid", ";", "FCB", "*", "fcb", ";", "SCB", "*", "scb", ";", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "if", "(", "port", "<", "NOPORT", "||", "port", ">", "MAX_PORT", ")", "{", "err", "=", "true", ";", "}", "else", "{", "if", "(", "FCB_reserve", "(", "1", ",", "&", "fid", ",", "&", "fcb", ")", "==", "1", ")", "{", "scb", "=", "(", "SCB", "*", ")", "socket_init", "(", ")", ";", "scb", "->", "refcount", "=", "1", ";", "scb", "->", "type", "=", "UNBOUND", ";", "scb", "->", "portnum", "=", "port", ";", "fcb", "->", "streamobj", "=", "scb", ";", "fcb", "->", "streamfunc", "=", "&", "socket_fops", ";", "}", "else", "{", "err", "=", "true", ";", "}", "}", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "switch", "(", "err", ")", "{", "case", "false", ":", "return", "fid", ";", "case", "true", ":", "return", "NOFILE", ";", "}", "return", "NOFILE", ";", "}" ]
Create and initialize an UNBOUND socket control block.
[ "Create", "and", "initialize", "an", "UNBOUND", "socket", "control", "block", "." ]
[ "/** Error check. */", "/** Check for enough fid's */" ]
[ { "param": "port", "type": "port_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "port", "type": "port_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
Listen
int
int Listen(Fid_t sock) { bool err = false; SCB* scb; FCB* fcb; PCB* curr = CURPROC; Mutex_Lock(& kernel_mutex); /** Error checks. */ if (sock < MAX_FILEID && curr->FIDT[sock] != NULL && sock != NOFILE) { fcb = get_fcb(sock); scb = (SCB*) fcb->streamobj; if (scb->portnum == NOPORT || scb->type != UNBOUND || OccupiedPorts[scb->portnum] == true) { err = true; } else { scb->type = LISTENER; scb->listener.cv = COND_INIT; rlnode_init(& scb->listener.request_list, NULL); /** Hold info about which port we occupie. */ OccupiedPorts[scb->portnum] = true; PortSockets[scb->portnum] = sock; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return 0; case true: return -1; } return -1; }
/** Further initialize an UNBOUND socket as a LISTENER. */
Further initialize an UNBOUND socket as a LISTENER.
[ "Further", "initialize", "an", "UNBOUND", "socket", "as", "a", "LISTENER", "." ]
int Listen(Fid_t sock) { bool err = false; SCB* scb; FCB* fcb; PCB* curr = CURPROC; Mutex_Lock(& kernel_mutex); if (sock < MAX_FILEID && curr->FIDT[sock] != NULL && sock != NOFILE) { fcb = get_fcb(sock); scb = (SCB*) fcb->streamobj; if (scb->portnum == NOPORT || scb->type != UNBOUND || OccupiedPorts[scb->portnum] == true) { err = true; } else { scb->type = LISTENER; scb->listener.cv = COND_INIT; rlnode_init(& scb->listener.request_list, NULL); OccupiedPorts[scb->portnum] = true; PortSockets[scb->portnum] = sock; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return 0; case true: return -1; } return -1; }
[ "int", "Listen", "(", "Fid_t", "sock", ")", "{", "bool", "err", "=", "false", ";", "SCB", "*", "scb", ";", "FCB", "*", "fcb", ";", "PCB", "*", "curr", "=", "CURPROC", ";", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "if", "(", "sock", "<", "MAX_FILEID", "&&", "curr", "->", "FIDT", "[", "sock", "]", "!=", "NULL", "&&", "sock", "!=", "NOFILE", ")", "{", "fcb", "=", "get_fcb", "(", "sock", ")", ";", "scb", "=", "(", "SCB", "*", ")", "fcb", "->", "streamobj", ";", "if", "(", "scb", "->", "portnum", "==", "NOPORT", "||", "scb", "->", "type", "!=", "UNBOUND", "||", "OccupiedPorts", "[", "scb", "->", "portnum", "]", "==", "true", ")", "{", "err", "=", "true", ";", "}", "else", "{", "scb", "->", "type", "=", "LISTENER", ";", "scb", "->", "listener", ".", "cv", "=", "COND_INIT", ";", "rlnode_init", "(", "&", "scb", "->", "listener", ".", "request_list", ",", "NULL", ")", ";", "OccupiedPorts", "[", "scb", "->", "portnum", "]", "=", "true", ";", "PortSockets", "[", "scb", "->", "portnum", "]", "=", "sock", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "switch", "(", "err", ")", "{", "case", "false", ":", "return", "0", ";", "case", "true", ":", "return", "-1", ";", "}", "return", "-1", ";", "}" ]
Further initialize an UNBOUND socket as a LISTENER.
[ "Further", "initialize", "an", "UNBOUND", "socket", "as", "a", "LISTENER", "." ]
[ "/** Error checks. */", "/** Hold info about which port we occupie. */" ]
[ { "param": "sock", "type": "Fid_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sock", "type": "Fid_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
Accept
Fid_t
Fid_t Accept(Fid_t lsock) { bool err = false; Fid_t pfid; SCB* lscb, * pscb; FCB* lfcb, *pfcb; PCB* curr = CURPROC; RCB* rcb; pipe_t pipe_1, pipe_2; Mutex_Lock(& kernel_mutex); /** Error checks. */ if (lsock<MAX_FILEID && curr->FIDT[lsock]!=NULL) { lfcb = get_fcb(lsock); lscb = (SCB*) lfcb->streamobj; /** Error checks. */ if (lscb->type == LISTENER ) { /** While request list is empty, wait for connections. */ while (is_rlist_empty(& lscb->listener.request_list) == 1) Cond_Wait(& kernel_mutex, &lscb->listener.cv); /** Check if there are enough fids. */ if (FCB_reserve(1, &pfid, &pfcb) == 1){ /** Initiate the PEER socket. */ pscb = (SCB*) socket_init(); pscb->refcount = 0; pscb->type = PEER; pscb->portnum = 0; pfcb->streamobj = pscb; pfcb->streamfunc = &socket_fops; Mutex_Unlock(& kernel_mutex); /** Create the pipes to be used by the peers. */ if (Pipe(& pipe_1) == 0 && Pipe(& pipe_2) == 0) { Mutex_Lock(& kernel_mutex); /** Link everything up. */ rcb = rlist_pop_front(& lscb->listener.request_list)->rcb; pscb->peer.peer2 = rcb->scb; pscb->peer.fid_send = pipe_1.write; pscb->peer.fid_receive = pipe_2.read; rcb->scb->peer.peer2 = pscb; rcb->scb->peer.fid_send = pipe_1.read; rcb->scb->peer.fid_receive = pipe_2.write; rcb->flag = true; Cond_Signal(& rcb->cv); } else{ Mutex_Lock(& kernel_mutex); err = true; } } else { err = true; } } else { err = true; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return pfid; case true: return NOFILE; } return NOFILE; }
/** Check if all is ok and create a PEER socket to receive the I/O of the connecting PEER. */
Check if all is ok and create a PEER socket to receive the I/O of the connecting PEER.
[ "Check", "if", "all", "is", "ok", "and", "create", "a", "PEER", "socket", "to", "receive", "the", "I", "/", "O", "of", "the", "connecting", "PEER", "." ]
Fid_t Accept(Fid_t lsock) { bool err = false; Fid_t pfid; SCB* lscb, * pscb; FCB* lfcb, *pfcb; PCB* curr = CURPROC; RCB* rcb; pipe_t pipe_1, pipe_2; Mutex_Lock(& kernel_mutex); if (lsock<MAX_FILEID && curr->FIDT[lsock]!=NULL) { lfcb = get_fcb(lsock); lscb = (SCB*) lfcb->streamobj; if (lscb->type == LISTENER ) { while (is_rlist_empty(& lscb->listener.request_list) == 1) Cond_Wait(& kernel_mutex, &lscb->listener.cv); if (FCB_reserve(1, &pfid, &pfcb) == 1){ pscb = (SCB*) socket_init(); pscb->refcount = 0; pscb->type = PEER; pscb->portnum = 0; pfcb->streamobj = pscb; pfcb->streamfunc = &socket_fops; Mutex_Unlock(& kernel_mutex); if (Pipe(& pipe_1) == 0 && Pipe(& pipe_2) == 0) { Mutex_Lock(& kernel_mutex); rcb = rlist_pop_front(& lscb->listener.request_list)->rcb; pscb->peer.peer2 = rcb->scb; pscb->peer.fid_send = pipe_1.write; pscb->peer.fid_receive = pipe_2.read; rcb->scb->peer.peer2 = pscb; rcb->scb->peer.fid_send = pipe_1.read; rcb->scb->peer.fid_receive = pipe_2.write; rcb->flag = true; Cond_Signal(& rcb->cv); } else{ Mutex_Lock(& kernel_mutex); err = true; } } else { err = true; } } else { err = true; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return pfid; case true: return NOFILE; } return NOFILE; }
[ "Fid_t", "Accept", "(", "Fid_t", "lsock", ")", "{", "bool", "err", "=", "false", ";", "Fid_t", "pfid", ";", "SCB", "*", "lscb", ",", "*", "pscb", ";", "FCB", "*", "lfcb", ",", "*", "pfcb", ";", "PCB", "*", "curr", "=", "CURPROC", ";", "RCB", "*", "rcb", ";", "pipe_t", "pipe_1", ",", "pipe_2", ";", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "if", "(", "lsock", "<", "MAX_FILEID", "&&", "curr", "->", "FIDT", "[", "lsock", "]", "!=", "NULL", ")", "{", "lfcb", "=", "get_fcb", "(", "lsock", ")", ";", "lscb", "=", "(", "SCB", "*", ")", "lfcb", "->", "streamobj", ";", "if", "(", "lscb", "->", "type", "==", "LISTENER", ")", "{", "while", "(", "is_rlist_empty", "(", "&", "lscb", "->", "listener", ".", "request_list", ")", "==", "1", ")", "Cond_Wait", "(", "&", "kernel_mutex", ",", "&", "lscb", "->", "listener", ".", "cv", ")", ";", "if", "(", "FCB_reserve", "(", "1", ",", "&", "pfid", ",", "&", "pfcb", ")", "==", "1", ")", "{", "pscb", "=", "(", "SCB", "*", ")", "socket_init", "(", ")", ";", "pscb", "->", "refcount", "=", "0", ";", "pscb", "->", "type", "=", "PEER", ";", "pscb", "->", "portnum", "=", "0", ";", "pfcb", "->", "streamobj", "=", "pscb", ";", "pfcb", "->", "streamfunc", "=", "&", "socket_fops", ";", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "if", "(", "Pipe", "(", "&", "pipe_1", ")", "==", "0", "&&", "Pipe", "(", "&", "pipe_2", ")", "==", "0", ")", "{", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "rcb", "=", "rlist_pop_front", "(", "&", "lscb", "->", "listener", ".", "request_list", ")", "->", "rcb", ";", "pscb", "->", "peer", ".", "peer2", "=", "rcb", "->", "scb", ";", "pscb", "->", "peer", ".", "fid_send", "=", "pipe_1", ".", "write", ";", "pscb", "->", "peer", ".", "fid_receive", "=", "pipe_2", ".", "read", ";", "rcb", "->", "scb", "->", "peer", ".", "peer2", "=", "pscb", ";", "rcb", "->", "scb", "->", "peer", ".", "fid_send", "=", "pipe_1", ".", "read", ";", "rcb", "->", "scb", "->", "peer", ".", "fid_receive", "=", "pipe_2", ".", "write", ";", "rcb", "->", "flag", "=", "true", ";", "Cond_Signal", "(", "&", "rcb", "->", "cv", ")", ";", "}", "else", "{", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "err", "=", "true", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "switch", "(", "err", ")", "{", "case", "false", ":", "return", "pfid", ";", "case", "true", ":", "return", "NOFILE", ";", "}", "return", "NOFILE", ";", "}" ]
Check if all is ok and create a PEER socket to receive the I/O of the connecting PEER.
[ "Check", "if", "all", "is", "ok", "and", "create", "a", "PEER", "socket", "to", "receive", "the", "I", "/", "O", "of", "the", "connecting", "PEER", "." ]
[ "/** Error checks. */", "/** Error checks. */", "/** While request list is empty, wait for connections. */", "/** Check if there are enough fids. */", "/** Initiate the PEER socket. */", "/** Create the pipes to be used by the peers. */", "/** Link everything up. */" ]
[ { "param": "lsock", "type": "Fid_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "lsock", "type": "Fid_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
Connect
int
int Connect(Fid_t sock, port_t port, timeout_t timeout) { bool err = false; SCB* lscb, * pscb; RCB* rcb; Mutex_Lock(& kernel_mutex); /** Error checks. */ if (port != NOPORT && port <= MAX_PORT && OccupiedPorts[port] == true ){ lscb = get_fcb(PortSockets[port])->streamobj; pscb = get_fcb(sock)->streamobj; /** Error checks. */ if(pscb->type == UNBOUND){ /** Initialize the RCB to bw pushed into the Listener's list. */ rcb = (RCB*) request_init(); rlnode_init(& rcb->node, rcb); rcb->scb = pscb; rcb->cv = COND_INIT; rcb->flag = false; rlist_push_back(& lscb->listener.request_list, & rcb->node); /** Signal the listener that it has a request. */ Cond_Signal(& lscb->listener.cv); /** Wait to be processed by Accept. */ Cond_Wait(& kernel_mutex, & rcb->cv); usleep(timeout*10); /** If not processed by the end of timeout return error. */ if (rcb->flag == false){ err = true; } } else { err = true; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return 0; case true: return -1; } return -1; }
/** Create a connection request to the listening socket occupying the given port. */
Create a connection request to the listening socket occupying the given port.
[ "Create", "a", "connection", "request", "to", "the", "listening", "socket", "occupying", "the", "given", "port", "." ]
int Connect(Fid_t sock, port_t port, timeout_t timeout) { bool err = false; SCB* lscb, * pscb; RCB* rcb; Mutex_Lock(& kernel_mutex); if (port != NOPORT && port <= MAX_PORT && OccupiedPorts[port] == true ){ lscb = get_fcb(PortSockets[port])->streamobj; pscb = get_fcb(sock)->streamobj; if(pscb->type == UNBOUND){ rcb = (RCB*) request_init(); rlnode_init(& rcb->node, rcb); rcb->scb = pscb; rcb->cv = COND_INIT; rcb->flag = false; rlist_push_back(& lscb->listener.request_list, & rcb->node); Cond_Signal(& lscb->listener.cv); Cond_Wait(& kernel_mutex, & rcb->cv); usleep(timeout*10); if (rcb->flag == false){ err = true; } } else { err = true; } } else { err = true; } Mutex_Unlock(& kernel_mutex); switch (err) { case false: return 0; case true: return -1; } return -1; }
[ "int", "Connect", "(", "Fid_t", "sock", ",", "port_t", "port", ",", "timeout_t", "timeout", ")", "{", "bool", "err", "=", "false", ";", "SCB", "*", "lscb", ",", "*", "pscb", ";", "RCB", "*", "rcb", ";", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "if", "(", "port", "!=", "NOPORT", "&&", "port", "<=", "MAX_PORT", "&&", "OccupiedPorts", "[", "port", "]", "==", "true", ")", "{", "lscb", "=", "get_fcb", "(", "PortSockets", "[", "port", "]", ")", "->", "streamobj", ";", "pscb", "=", "get_fcb", "(", "sock", ")", "->", "streamobj", ";", "if", "(", "pscb", "->", "type", "==", "UNBOUND", ")", "{", "rcb", "=", "(", "RCB", "*", ")", "request_init", "(", ")", ";", "rlnode_init", "(", "&", "rcb", "->", "node", ",", "rcb", ")", ";", "rcb", "->", "scb", "=", "pscb", ";", "rcb", "->", "cv", "=", "COND_INIT", ";", "rcb", "->", "flag", "=", "false", ";", "rlist_push_back", "(", "&", "lscb", "->", "listener", ".", "request_list", ",", "&", "rcb", "->", "node", ")", ";", "Cond_Signal", "(", "&", "lscb", "->", "listener", ".", "cv", ")", ";", "Cond_Wait", "(", "&", "kernel_mutex", ",", "&", "rcb", "->", "cv", ")", ";", "usleep", "(", "timeout", "*", "10", ")", ";", "if", "(", "rcb", "->", "flag", "==", "false", ")", "{", "err", "=", "true", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "}", "else", "{", "err", "=", "true", ";", "}", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "switch", "(", "err", ")", "{", "case", "false", ":", "return", "0", ";", "case", "true", ":", "return", "-1", ";", "}", "return", "-1", ";", "}" ]
Create a connection request to the listening socket occupying the given port.
[ "Create", "a", "connection", "request", "to", "the", "listening", "socket", "occupying", "the", "given", "port", "." ]
[ "/** Error checks. */", "/** Error checks. */", "/** Initialize the RCB to bw pushed into the Listener's list. */", "/** Signal the listener that it has a request. */", "/** Wait to be processed by Accept. */", "/** If not processed by the end of timeout return error. */" ]
[ { "param": "sock", "type": "Fid_t" }, { "param": "port", "type": "port_t" }, { "param": "timeout", "type": "timeout_t" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sock", "type": "Fid_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "port", "type": "port_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "timeout", "type": "timeout_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2f398e3e1a248faec6825c3b5e824d3e2bb13278
TedPap/opsys
kernel_socket.c
[ "MIT" ]
C
ShutDown
int
int ShutDown(Fid_t sock, shutdown_mode how) { Fid_t soc_read, soc_write; FCB* fcb; SCB* scb; Mutex_Lock(& kernel_mutex); fcb = get_fcb(sock); scb = fcb->streamobj; soc_read = scb->peer.fid_receive; soc_write = scb->peer.fid_send; switch (how) { case SHUTDOWN_READ: Mutex_Unlock(& kernel_mutex); Close(soc_read); case SHUTDOWN_WRITE: Mutex_Unlock(& kernel_mutex); Close(soc_write); case SHUTDOWN_BOTH: Mutex_Unlock(& kernel_mutex); Close(soc_read); Close(soc_write); Close(sock); } return -1; }
/** Close the right fids depending on the shutdown mode*/
Close the right fids depending on the shutdown mode
[ "Close", "the", "right", "fids", "depending", "on", "the", "shutdown", "mode" ]
int ShutDown(Fid_t sock, shutdown_mode how) { Fid_t soc_read, soc_write; FCB* fcb; SCB* scb; Mutex_Lock(& kernel_mutex); fcb = get_fcb(sock); scb = fcb->streamobj; soc_read = scb->peer.fid_receive; soc_write = scb->peer.fid_send; switch (how) { case SHUTDOWN_READ: Mutex_Unlock(& kernel_mutex); Close(soc_read); case SHUTDOWN_WRITE: Mutex_Unlock(& kernel_mutex); Close(soc_write); case SHUTDOWN_BOTH: Mutex_Unlock(& kernel_mutex); Close(soc_read); Close(soc_write); Close(sock); } return -1; }
[ "int", "ShutDown", "(", "Fid_t", "sock", ",", "shutdown_mode", "how", ")", "{", "Fid_t", "soc_read", ",", "soc_write", ";", "FCB", "*", "fcb", ";", "SCB", "*", "scb", ";", "Mutex_Lock", "(", "&", "kernel_mutex", ")", ";", "fcb", "=", "get_fcb", "(", "sock", ")", ";", "scb", "=", "fcb", "->", "streamobj", ";", "soc_read", "=", "scb", "->", "peer", ".", "fid_receive", ";", "soc_write", "=", "scb", "->", "peer", ".", "fid_send", ";", "switch", "(", "how", ")", "{", "case", "SHUTDOWN_READ", ":", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "Close", "(", "soc_read", ")", ";", "case", "SHUTDOWN_WRITE", ":", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "Close", "(", "soc_write", ")", ";", "case", "SHUTDOWN_BOTH", ":", "Mutex_Unlock", "(", "&", "kernel_mutex", ")", ";", "Close", "(", "soc_read", ")", ";", "Close", "(", "soc_write", ")", ";", "Close", "(", "sock", ")", ";", "}", "return", "-1", ";", "}" ]
Close the right fids depending on the shutdown mode
[ "Close", "the", "right", "fids", "depending", "on", "the", "shutdown", "mode" ]
[]
[ { "param": "sock", "type": "Fid_t" }, { "param": "how", "type": "shutdown_mode" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sock", "type": "Fid_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "how", "type": "shutdown_mode", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2031d224e3d5304ad6dfa577134aa78b5601a6b2
TedPap/opsys
validate_api.c
[ "MIT" ]
C
data_producer
int
int data_producer(int argl, void* args) { assert(argl == sizeof(int)); int nbytes = *(int*)args; int i = 0; Close(0); char buffer[32768]; while(nbytes>0) { unsigned int n = (nbytes<32768) ? nbytes : 32768; int rc = Write(1, buffer, n); assert(rc>0); nbytes -= rc; i++; } Close(1); return 0; }
/* Takes one integer argument, writes that many bytes to stdout. */
Takes one integer argument, writes that many bytes to stdout.
[ "Takes", "one", "integer", "argument", "writes", "that", "many", "bytes", "to", "stdout", "." ]
int data_producer(int argl, void* args) { assert(argl == sizeof(int)); int nbytes = *(int*)args; int i = 0; Close(0); char buffer[32768]; while(nbytes>0) { unsigned int n = (nbytes<32768) ? nbytes : 32768; int rc = Write(1, buffer, n); assert(rc>0); nbytes -= rc; i++; } Close(1); return 0; }
[ "int", "data_producer", "(", "int", "argl", ",", "void", "*", "args", ")", "{", "assert", "(", "argl", "==", "sizeof", "(", "int", ")", ")", ";", "int", "nbytes", "=", "*", "(", "int", "*", ")", "args", ";", "int", "i", "=", "0", ";", "Close", "(", "0", ")", ";", "char", "buffer", "[", "32768", "]", ";", "while", "(", "nbytes", ">", "0", ")", "{", "unsigned", "int", "n", "=", "(", "nbytes", "<", "32768", ")", "?", "nbytes", ":", "32768", ";", "int", "rc", "=", "Write", "(", "1", ",", "buffer", ",", "n", ")", ";", "assert", "(", "rc", ">", "0", ")", ";", "nbytes", "-=", "rc", ";", "i", "++", ";", "}", "Close", "(", "1", ")", ";", "return", "0", ";", "}" ]
Takes one integer argument, writes that many bytes to stdout.
[ "Takes", "one", "integer", "argument", "writes", "that", "many", "bytes", "to", "stdout", "." ]
[]
[ { "param": "argl", "type": "int" }, { "param": "args", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argl", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
2031d224e3d5304ad6dfa577134aa78b5601a6b2
TedPap/opsys
validate_api.c
[ "MIT" ]
C
data_consumer
int
int data_consumer(int argl, void* args) { assert(argl == sizeof(int)); int nbytes = *(int*)args; Close(1); char buffer[16384]; int count = 0; int rc = 1; while(rc) { rc = Read(0, buffer, 16384); assert(rc>=0); count += rc; } ASSERT(count == nbytes); return 0; }
/* Takes one integer argument. Reads its standard input to exhaustion, asserts it read that many bytes. */
Takes one integer argument. Reads its standard input to exhaustion, asserts it read that many bytes.
[ "Takes", "one", "integer", "argument", ".", "Reads", "its", "standard", "input", "to", "exhaustion", "asserts", "it", "read", "that", "many", "bytes", "." ]
int data_consumer(int argl, void* args) { assert(argl == sizeof(int)); int nbytes = *(int*)args; Close(1); char buffer[16384]; int count = 0; int rc = 1; while(rc) { rc = Read(0, buffer, 16384); assert(rc>=0); count += rc; } ASSERT(count == nbytes); return 0; }
[ "int", "data_consumer", "(", "int", "argl", ",", "void", "*", "args", ")", "{", "assert", "(", "argl", "==", "sizeof", "(", "int", ")", ")", ";", "int", "nbytes", "=", "*", "(", "int", "*", ")", "args", ";", "Close", "(", "1", ")", ";", "char", "buffer", "[", "16384", "]", ";", "int", "count", "=", "0", ";", "int", "rc", "=", "1", ";", "while", "(", "rc", ")", "{", "rc", "=", "Read", "(", "0", ",", "buffer", ",", "16384", ")", ";", "assert", "(", "rc", ">=", "0", ")", ";", "count", "+=", "rc", ";", "}", "ASSERT", "(", "count", "==", "nbytes", ")", ";", "return", "0", ";", "}" ]
Takes one integer argument.
[ "Takes", "one", "integer", "argument", "." ]
[]
[ { "param": "argl", "type": "int" }, { "param": "args", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argl", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "args", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
interrupt_pic_thread
void
static inline void interrupt_pic_thread() { union sigval coreval; coreval.sival_ptr = NULL; /* This is silly, but silences valgrind */ coreval.sival_int = -1; CHECKRC(pthread_sigqueue(PIC_thread, SIGUSR1, coreval)); __atomic_fetch_add(&PIC_usr1_queued,1,__ATOMIC_RELAXED); }
/* Cause PIC daemon to loop. */
Cause PIC daemon to loop.
[ "Cause", "PIC", "daemon", "to", "loop", "." ]
static inline void interrupt_pic_thread() { union sigval coreval; coreval.sival_ptr = NULL; coreval.sival_int = -1; CHECKRC(pthread_sigqueue(PIC_thread, SIGUSR1, coreval)); __atomic_fetch_add(&PIC_usr1_queued,1,__ATOMIC_RELAXED); }
[ "static", "inline", "void", "interrupt_pic_thread", "(", ")", "{", "union", "sigval", "coreval", ";", "coreval", ".", "sival_ptr", "=", "NULL", ";", "coreval", ".", "sival_int", "=", "-1", ";", "CHECKRC", "(", "pthread_sigqueue", "(", "PIC_thread", ",", "SIGUSR1", ",", "coreval", ")", ")", ";", "__atomic_fetch_add", "(", "&", "PIC_usr1_queued", ",", "1", ",", "__ATOMIC_RELAXED", ")", ";", "}" ]
Cause PIC daemon to loop.
[ "Cause", "PIC", "daemon", "to", "loop", "." ]
[ "/* This is silly, but silences valgrind */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
bootfunc_wrapper
void
static void* bootfunc_wrapper(void* _core) { Core* core = (Core*)_core; /* Default interrupt handlers */ for(int i=0; i<maximum_interrupt_no; i++) { core->intvec[i] = NULL; core->intpending[i] = 0; } /* Mark interrupts as enabled */ core->int_disabled = 0; /* establish the thread-local id */ CHECKRC(pthread_setspecific(Core_key, core)); cpu_core_id = core->id; /* Set core signal mask */ CHECKRC(pthread_sigmask(SIG_BLOCK, &core_signal_set, NULL)); /* create a thread-specific timer */ core->timer_sigevent.sigev_notify = SIGEV_SIGNAL; core->timer_sigevent.sigev_signo = SIGALRM; core->timer_sigevent.sigev_value.sival_int = core->id; CHECK(timer_create(CLOCK_REALTIME, & core->timer_sigevent, & core->timer_id)); /* sync with all cores */ pthread_barrier_wait(& system_barrier); /* execute the boot code */ core->bootfunc(); /* Reset interrupt handlers to null, to stop processing interrupts. */ for(int i=0; i<maximum_interrupt_no; i++) { core->intvec[i] = NULL; } /* Delete the core timer */ CHECK(timer_delete(core->timer_id)); pthread_barrier_wait(& core_barrier); /* Stop PIC daemon */ if(core->id==0) { PIC_active = 0; interrupt_pic_thread(); } /* sync with all cores */ pthread_barrier_wait(& system_barrier); return _core; }
/* Helper pthread-startable function to launch a core thread. */
Helper pthread-startable function to launch a core thread.
[ "Helper", "pthread", "-", "startable", "function", "to", "launch", "a", "core", "thread", "." ]
static void* bootfunc_wrapper(void* _core) { Core* core = (Core*)_core; for(int i=0; i<maximum_interrupt_no; i++) { core->intvec[i] = NULL; core->intpending[i] = 0; } core->int_disabled = 0; CHECKRC(pthread_setspecific(Core_key, core)); cpu_core_id = core->id; CHECKRC(pthread_sigmask(SIG_BLOCK, &core_signal_set, NULL)); core->timer_sigevent.sigev_notify = SIGEV_SIGNAL; core->timer_sigevent.sigev_signo = SIGALRM; core->timer_sigevent.sigev_value.sival_int = core->id; CHECK(timer_create(CLOCK_REALTIME, & core->timer_sigevent, & core->timer_id)); pthread_barrier_wait(& system_barrier); core->bootfunc(); for(int i=0; i<maximum_interrupt_no; i++) { core->intvec[i] = NULL; } CHECK(timer_delete(core->timer_id)); pthread_barrier_wait(& core_barrier); if(core->id==0) { PIC_active = 0; interrupt_pic_thread(); } pthread_barrier_wait(& system_barrier); return _core; }
[ "static", "void", "*", "bootfunc_wrapper", "(", "void", "*", "_core", ")", "{", "Core", "*", "core", "=", "(", "Core", "*", ")", "_core", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maximum_interrupt_no", ";", "i", "++", ")", "{", "core", "->", "intvec", "[", "i", "]", "=", "NULL", ";", "core", "->", "intpending", "[", "i", "]", "=", "0", ";", "}", "core", "->", "int_disabled", "=", "0", ";", "CHECKRC", "(", "pthread_setspecific", "(", "Core_key", ",", "core", ")", ")", ";", "cpu_core_id", "=", "core", "->", "id", ";", "CHECKRC", "(", "pthread_sigmask", "(", "SIG_BLOCK", ",", "&", "core_signal_set", ",", "NULL", ")", ")", ";", "core", "->", "timer_sigevent", ".", "sigev_notify", "=", "SIGEV_SIGNAL", ";", "core", "->", "timer_sigevent", ".", "sigev_signo", "=", "SIGALRM", ";", "core", "->", "timer_sigevent", ".", "sigev_value", ".", "sival_int", "=", "core", "->", "id", ";", "CHECK", "(", "timer_create", "(", "CLOCK_REALTIME", ",", "&", "core", "->", "timer_sigevent", ",", "&", "core", "->", "timer_id", ")", ")", ";", "pthread_barrier_wait", "(", "&", "system_barrier", ")", ";", "core", "->", "bootfunc", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maximum_interrupt_no", ";", "i", "++", ")", "{", "core", "->", "intvec", "[", "i", "]", "=", "NULL", ";", "}", "CHECK", "(", "timer_delete", "(", "core", "->", "timer_id", ")", ")", ";", "pthread_barrier_wait", "(", "&", "core_barrier", ")", ";", "if", "(", "core", "->", "id", "==", "0", ")", "{", "PIC_active", "=", "0", ";", "interrupt_pic_thread", "(", ")", ";", "}", "pthread_barrier_wait", "(", "&", "system_barrier", ")", ";", "return", "_core", ";", "}" ]
Helper pthread-startable function to launch a core thread.
[ "Helper", "pthread", "-", "startable", "function", "to", "launch", "a", "core", "thread", "." ]
[ "/* Default interrupt handlers */", "/* Mark interrupts as enabled */", "/* establish the thread-local id */", "/* Set core signal mask */", "/* create a thread-specific timer */", "/* sync with all cores */", "/* execute the boot code */", "/* Reset interrupt handlers to null, to stop processing interrupts. */", "/* Delete the core timer */", "/* Stop PIC daemon */", "/* sync with all cores */" ]
[ { "param": "_core", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "_core", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
raise_interrupt
void
static inline void raise_interrupt(Core* core, Interrupt intno) { union sigval coreval; coreval.sival_ptr = NULL; /* This is to silence valgrind */ coreval.sival_int = core->id; core->intpending[intno] = 1; core->irq_raised[intno] ++; CHECKRC(pthread_sigqueue(core->thread, SIGUSR1, coreval)); cpu_core_restart(core->id); }
/* Raise an interrupt to a core. */
Raise an interrupt to a core.
[ "Raise", "an", "interrupt", "to", "a", "core", "." ]
static inline void raise_interrupt(Core* core, Interrupt intno) { union sigval coreval; coreval.sival_ptr = NULL; coreval.sival_int = core->id; core->intpending[intno] = 1; core->irq_raised[intno] ++; CHECKRC(pthread_sigqueue(core->thread, SIGUSR1, coreval)); cpu_core_restart(core->id); }
[ "static", "inline", "void", "raise_interrupt", "(", "Core", "*", "core", ",", "Interrupt", "intno", ")", "{", "union", "sigval", "coreval", ";", "coreval", ".", "sival_ptr", "=", "NULL", ";", "coreval", ".", "sival_int", "=", "core", "->", "id", ";", "core", "->", "intpending", "[", "intno", "]", "=", "1", ";", "core", "->", "irq_raised", "[", "intno", "]", "++", ";", "CHECKRC", "(", "pthread_sigqueue", "(", "core", "->", "thread", ",", "SIGUSR1", ",", "coreval", ")", ")", ";", "cpu_core_restart", "(", "core", "->", "id", ")", ";", "}" ]
Raise an interrupt to a core.
[ "Raise", "an", "interrupt", "to", "a", "core", "." ]
[ "/* This is to silence valgrind */" ]
[ { "param": "core", "type": "Core" }, { "param": "intno", "type": "Interrupt" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "core", "type": "Core", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "intno", "type": "Interrupt", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
dispatch_interrupts
void
static void dispatch_interrupts(Core* core) { for(int intno = 0; intno < maximum_interrupt_no; intno++) { if(core->int_disabled) break; /* will continue at cpu_interrupt_enable()*/ if(core->intpending[intno]) { core->intpending[intno] = 0; core->irq_delivered[intno]++; interrupt_handler* handler = core->intvec[intno]; if(handler != NULL) { handler(); } } } }
/* Dispatch the pending iterrupts for the given core. */
Dispatch the pending iterrupts for the given core.
[ "Dispatch", "the", "pending", "iterrupts", "for", "the", "given", "core", "." ]
static void dispatch_interrupts(Core* core) { for(int intno = 0; intno < maximum_interrupt_no; intno++) { if(core->int_disabled) break; if(core->intpending[intno]) { core->intpending[intno] = 0; core->irq_delivered[intno]++; interrupt_handler* handler = core->intvec[intno]; if(handler != NULL) { handler(); } } } }
[ "static", "void", "dispatch_interrupts", "(", "Core", "*", "core", ")", "{", "for", "(", "int", "intno", "=", "0", ";", "intno", "<", "maximum_interrupt_no", ";", "intno", "++", ")", "{", "if", "(", "core", "->", "int_disabled", ")", "break", ";", "if", "(", "core", "->", "intpending", "[", "intno", "]", ")", "{", "core", "->", "intpending", "[", "intno", "]", "=", "0", ";", "core", "->", "irq_delivered", "[", "intno", "]", "++", ";", "interrupt_handler", "*", "handler", "=", "core", "->", "intvec", "[", "intno", "]", ";", "if", "(", "handler", "!=", "NULL", ")", "{", "handler", "(", ")", ";", "}", "}", "}", "}" ]
Dispatch the pending iterrupts for the given core.
[ "Dispatch", "the", "pending", "iterrupts", "for", "the", "given", "core", "." ]
[ "/* will continue at\n\t\t\t\t\t\t\t\t\t\t cpu_interrupt_enable()*/" ]
[ { "param": "core", "type": "Core" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "core", "type": "Core", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
sigusr1_handler
void
static void sigusr1_handler(int signo, siginfo_t* si, void* ctx) { Core* core = & CORE[si->si_value.sival_int]; core->irq_count++; if(core->int_disabled) return; dispatch_interrupts(core); }
/* This is the handler run by core threads to handle interrupts. */
This is the handler run by core threads to handle interrupts.
[ "This", "is", "the", "handler", "run", "by", "core", "threads", "to", "handle", "interrupts", "." ]
static void sigusr1_handler(int signo, siginfo_t* si, void* ctx) { Core* core = & CORE[si->si_value.sival_int]; core->irq_count++; if(core->int_disabled) return; dispatch_interrupts(core); }
[ "static", "void", "sigusr1_handler", "(", "int", "signo", ",", "siginfo_t", "*", "si", ",", "void", "*", "ctx", ")", "{", "Core", "*", "core", "=", "&", "CORE", "[", "si", "->", "si_value", ".", "sival_int", "]", ";", "core", "->", "irq_count", "++", ";", "if", "(", "core", "->", "int_disabled", ")", "return", ";", "dispatch_interrupts", "(", "core", ")", ";", "}" ]
This is the handler run by core threads to handle interrupts.
[ "This", "is", "the", "handler", "run", "by", "core", "threads", "to", "handle", "interrupts", "." ]
[]
[ { "param": "signo", "type": "int" }, { "param": "si", "type": "siginfo_t" }, { "param": "ctx", "type": "void" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "signo", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "si", "type": "siginfo_t", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ctx", "type": "void", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3c5f22f5ba8f473ea852acac66d4dad0f16b7b8d
TedPap/opsys
bios.c
[ "MIT" ]
C
terminal_init
int
static int terminal_init(terminal* this, int no) { char fname[32]; int fd; sprintf(fname, "con%d", no); fd = open(fname, O_WRONLY); if(fd==-1) return -1; io_device_init(& this->con, fd, IODIR_TX); sprintf(fname, "kbd%d", no); fd = open(fname, O_RDONLY); if(fd==-1) return -1; io_device_init(& this->kbd, fd, IODIR_RX); return 0; }
/* Open the FIFOs for this terminal */
Open the FIFOs for this terminal
[ "Open", "the", "FIFOs", "for", "this", "terminal" ]
static int terminal_init(terminal* this, int no) { char fname[32]; int fd; sprintf(fname, "con%d", no); fd = open(fname, O_WRONLY); if(fd==-1) return -1; io_device_init(& this->con, fd, IODIR_TX); sprintf(fname, "kbd%d", no); fd = open(fname, O_RDONLY); if(fd==-1) return -1; io_device_init(& this->kbd, fd, IODIR_RX); return 0; }
[ "static", "int", "terminal_init", "(", "terminal", "*", "this", ",", "int", "no", ")", "{", "char", "fname", "[", "32", "]", ";", "int", "fd", ";", "sprintf", "(", "fname", ",", "\"", "\"", ",", "no", ")", ";", "fd", "=", "open", "(", "fname", ",", "O_WRONLY", ")", ";", "if", "(", "fd", "==", "-1", ")", "return", "-1", ";", "io_device_init", "(", "&", "this", "->", "con", ",", "fd", ",", "IODIR_TX", ")", ";", "sprintf", "(", "fname", ",", "\"", "\"", ",", "no", ")", ";", "fd", "=", "open", "(", "fname", ",", "O_RDONLY", ")", ";", "if", "(", "fd", "==", "-1", ")", "return", "-1", ";", "io_device_init", "(", "&", "this", "->", "kbd", ",", "fd", ",", "IODIR_RX", ")", ";", "return", "0", ";", "}" ]
Open the FIFOs for this terminal
[ "Open", "the", "FIFOs", "for", "this", "terminal" ]
[]
[ { "param": "this", "type": "terminal" }, { "param": "no", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "this", "type": "terminal", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "no", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8a0c213be647b8d3a09658686b67ca7e6c606ed1
TedPap/opsys
kernel_dev.c
[ "MIT" ]
C
serial_rx_handler
void
void serial_rx_handler() { int pre = preempt_off; /* We do not know which terminal is ready, so we must signal them all ! */ for(int i=0;i<bios_serial_ports();i++) { serial_dcb_t* dcb = &serial_dcb[i]; Mutex_Lock(& dcb->spinlock); Cond_Broadcast(&dcb->rx_ready); Mutex_Unlock(& dcb->spinlock); } if(pre) preempt_on; }
/* Interrupt-driven driver for serial-device reads. */
Interrupt-driven driver for serial-device reads.
[ "Interrupt", "-", "driven", "driver", "for", "serial", "-", "device", "reads", "." ]
void serial_rx_handler() { int pre = preempt_off; for(int i=0;i<bios_serial_ports();i++) { serial_dcb_t* dcb = &serial_dcb[i]; Mutex_Lock(& dcb->spinlock); Cond_Broadcast(&dcb->rx_ready); Mutex_Unlock(& dcb->spinlock); } if(pre) preempt_on; }
[ "void", "serial_rx_handler", "(", ")", "{", "int", "pre", "=", "preempt_off", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bios_serial_ports", "(", ")", ";", "i", "++", ")", "{", "serial_dcb_t", "*", "dcb", "=", "&", "serial_dcb", "[", "i", "]", ";", "Mutex_Lock", "(", "&", "dcb", "->", "spinlock", ")", ";", "Cond_Broadcast", "(", "&", "dcb", "->", "rx_ready", ")", ";", "Mutex_Unlock", "(", "&", "dcb", "->", "spinlock", ")", ";", "}", "if", "(", "pre", ")", "preempt_on", ";", "}" ]
Interrupt-driven driver for serial-device reads.
[ "Interrupt", "-", "driven", "driver", "for", "serial", "-", "device", "reads", "." ]
[ "/* \n We do not know which terminal is\n ready, so we must signal them all !\n */" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }