Changeset View
Standalone View
source/blender/blenkernel/intern/object.c
| Show First 20 Lines • Show All 4,137 Lines • ▼ Show 20 Lines | else { | |||||||||
| } | } | |||||||||
| } | } | |||||||||
| } | } | |||||||||
| free_object_duplilist(lb); /* does restore */ | free_object_duplilist(lb); /* does restore */ | |||||||||
| return ok; | return ok; | |||||||||
| } | } | |||||||||
| struct GPencilStrokeIterData { | ||||||||||
campbellbarton: This isn't a stroke iterator, it iterates over stroke points, suggest… | ||||||||||
| const float (*obmat)[4]; | ||||||||||
| void (*func_cb)(const float[3], void *); | ||||||||||
campbellbartonUnsubmitted Not Done Inline Actions
Include arguments for clarity. campbellbarton: Include arguments for clarity. | ||||||||||
| void *user_data; | ||||||||||
| }; | ||||||||||
| static void foreach_display_point_gpencil_stroke_fn(bGPDlayer *UNUSED(layer), | ||||||||||
| bGPDframe *UNUSED(frame), | ||||||||||
| bGPDstroke *stroke, | ||||||||||
| void *thunk) | ||||||||||
| { | ||||||||||
| struct GPencilStrokeIterData *iter_data = thunk; | ||||||||||
| { | ||||||||||
| bGPDspoint *pt; | ||||||||||
| int i; | ||||||||||
| for (i = 0, pt = stroke->points; i < stroke->totpoints; i++, pt++) { | ||||||||||
| float co[3]; | ||||||||||
| mul_v3_m4v3(co, iter_data->obmat, &pt->x); | ||||||||||
| iter_data->func_cb(co, iter_data->user_data); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
| void BKE_object_foreach_display_point(Object *ob, | void BKE_object_foreach_display_point(Object *ob, | |||||||||
| const float obmat[4][4], | const float obmat[4][4], | |||||||||
| void (*func_cb)(const float[3], void *), | void (*func_cb)(const float[3], void *), | |||||||||
| void *user_data) | void *user_data) | |||||||||
| { | { | |||||||||
| /* TODO: pointcloud and hair objects support */ | /* TODO: pointcloud and hair objects support */ | |||||||||
| const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); | const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); | |||||||||
| float co[3]; | float co[3]; | |||||||||
| if (mesh_eval != NULL) { | if (mesh_eval != NULL) { | |||||||||
| const MVert *mv = mesh_eval->mvert; | const MVert *mv = mesh_eval->mvert; | |||||||||
| const int totvert = mesh_eval->totvert; | const int totvert = mesh_eval->totvert; | |||||||||
| for (int i = 0; i < totvert; i++, mv++) { | for (int i = 0; i < totvert; i++, mv++) { | |||||||||
| mul_v3_m4v3(co, obmat, mv->co); | mul_v3_m4v3(co, obmat, mv->co); | |||||||||
| func_cb(co, user_data); | func_cb(co, user_data); | |||||||||
| } | } | |||||||||
| } | } | |||||||||
| else if (ob->type == OB_GPENCIL) { | ||||||||||
| struct GPencilStrokeIterData iter_data = { | ||||||||||
| .obmat = obmat, .func_cb = func_cb, .user_data = user_data}; | ||||||||||
| BKE_gpencil_visible_stroke_iter( | ||||||||||
| ob->data, NULL, foreach_display_point_gpencil_stroke_fn, &iter_data); | ||||||||||
| } | ||||||||||
Done Inline ActionsInstead of this we could also run some simpler logic to iterate over the points, like BKE_gpencil_data_minmax() does. But that's effectively what BKE_gpencil_visible_stroke_iter() does as well, just with additional features that we don't use. Severin: Instead of this we could also run some simpler logic to iterate over the points, like… | ||||||||||
Not Done Inline ActionsThe problem with BKE_gpencil_data_minmax() is that is running for all datablock and for the preview we just need the active (visible) frames. The best solution would be to create a BKE_gpencil_strokes_visible_minmax() to consider only the active frames. If you agree, I can do it. antoniov: The problem with `BKE_gpencil_data_minmax()` is that is running for all datablock and for the… | ||||||||||
Not Done Inline ActionsMy mistake...looking at BKE_gpencil_data_minmax() does only active frame, so this is what we need. antoniov: My mistake...looking at BKE_gpencil_data_minmax() does only active frame, so this is what we… | ||||||||||
Done Inline Actions
Are you sure about that? It uses bGPDlayer.actframe for drawing.
We can't simply use the normal min-max calculation since that is axis aligned. The camera fitting should be view aligned. What BKE_camera_view_frame_fit_to_scene() does is iterate over visible points and executes a callback for each, we should just extend this iteration code to support the grease pencil case. Severin: > The problem with BKE_gpencil_data_minmax() is that is running for all datablock and for the… | ||||||||||
| else if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) { | else if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) { | |||||||||
| DispList *dl; | DispList *dl; | |||||||||
| for (dl = ob->runtime.curve_cache->disp.first; dl; dl = dl->next) { | for (dl = ob->runtime.curve_cache->disp.first; dl; dl = dl->next) { | |||||||||
| const float *v3 = dl->verts; | const float *v3 = dl->verts; | |||||||||
| int totvert = dl->nr; | int totvert = dl->nr; | |||||||||
| int i; | int i; | |||||||||
| ▲ Show 20 Lines • Show All 1,531 Lines • Show Last 20 Lines | ||||||||||
This isn't a stroke iterator, it iterates over stroke points, suggest GPencilStrokePointIterData.