Using the "Camera Fit Frame to Selected" operator didn't work for Grease Pencil
objects. The same issue caused grease pencil preview thumbnails to be useless
(e.g. when using "Mark Asset" on a Grease Pencil object).
Reason was that there was no logic to handle grease pencil data and its strokes
for the object display-point iterators used for the "Frame Selected" logic.
Details
- Reviewers
Campbell Barton (campbellbarton) Antonio Vazquez (antoniov) - Group Reviewers
Grease Pencil - Maniphest Tasks
- T89656: Asset preview not working with grease pencil objects
- Commits
- rB80d0b682905a: GPencil: Support camera "Frame Selected" and object previews
Diff Detail
- Repository
- rB Blender
Event Timeline
This is an alternative patch for T89656: Asset preview not working with grease pencil objects (the initial one being D11829: GPencil: Fix asset preview).
| source/blender/blenkernel/intern/object.c | ||
|---|---|---|
| 4192–4193 | Instead 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. | |
| source/blender/blenkernel/intern/object.c | ||
|---|---|---|
| 4192–4193 | The 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. | |
| source/blender/blenkernel/intern/object.c | ||
|---|---|---|
| 4192–4193 | My mistake...looking at BKE_gpencil_data_minmax() does only active frame, so this is what we need. | |
| source/blender/blenkernel/intern/object.c | ||
|---|---|---|
| 4192–4193 |
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. | |
One thing that's odd, for mesh objects we get the evaluated mesh through Object.runtime.data_eval (see BKE_object_get_evaluated_mesh()), so I'd expect that to be the evaluated grease pencil data for grease pencil objects. That's not the case though, it's NULL, so I directly use Object.data. Not sure if that is correct.
The eval data is in the gpd_eval datablock. I will test the patch and test how it's working with modifiers.