Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_manager_data.c
| Show First 20 Lines • Show All 948 Lines • ▼ Show 20 Lines | static void drw_sculpt_get_frustum_planes(Object *ob, float planes[6][4]) | ||||
| * The inverse cancels out here since we transform by inverse(obmat). */ | * The inverse cancels out here since we transform by inverse(obmat). */ | ||||
| float tmat[4][4]; | float tmat[4][4]; | ||||
| transpose_m4_m4(tmat, ob->obmat); | transpose_m4_m4(tmat, ob->obmat); | ||||
| for (int i = 0; i < 6; i++) { | for (int i = 0; i < 6; i++) { | ||||
| mul_m4_v4(tmat, planes[i]); | mul_m4_v4(tmat, planes[i]); | ||||
| } | } | ||||
| } | } | ||||
| static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd, bool use_vcol) | static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd) | ||||
| { | { | ||||
| /* PBVH should always exist for non-empty meshes, created by depsgrah eval. */ | /* PBVH should always exist for non-empty meshes, created by depsgrah eval. */ | ||||
| PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL; | PBVH *pbvh = (scd->ob->sculpt) ? scd->ob->sculpt->pbvh : NULL; | ||||
| if (!pbvh) { | if (!pbvh) { | ||||
| return; | return; | ||||
| } | } | ||||
| const DRWContextState *drwctx = DRW_context_state_get(); | const DRWContextState *drwctx = DRW_context_state_get(); | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd) | ||||
| if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) { | if (p && (p->flags & PAINT_SCULPT_DELAY_UPDATES)) { | ||||
| update_only_visible = true; | update_only_visible = true; | ||||
| } | } | ||||
| Mesh *mesh = scd->ob->data; | Mesh *mesh = scd->ob->data; | ||||
| BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg); | BKE_pbvh_update_normals(pbvh, mesh->runtime.subdiv_ccg); | ||||
| BKE_pbvh_draw_cb(pbvh, | BKE_pbvh_draw_cb(pbvh, | ||||
| use_vcol, | |||||
| update_only_visible, | update_only_visible, | ||||
| &update_frustum, | &update_frustum, | ||||
| &draw_frustum, | &draw_frustum, | ||||
| (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, | (void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb, | ||||
| scd); | scd); | ||||
| if (SCULPT_DEBUG_BUFFERS) { | if (SCULPT_DEBUG_BUFFERS) { | ||||
| int debug_node_nr = 0; | int debug_node_nr = 0; | ||||
| DRW_debug_modelmat(scd->ob->obmat); | DRW_debug_modelmat(scd->ob->obmat); | ||||
| BKE_pbvh_draw_debug_cb( | BKE_pbvh_draw_debug_cb( | ||||
| pbvh, | pbvh, | ||||
| (void (*)( | (void (*)( | ||||
| void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb, | void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb, | ||||
| &debug_node_nr); | &debug_node_nr); | ||||
| } | } | ||||
| } | } | ||||
| void DRW_shgroup_call_sculpt( | void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask) | ||||
| DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_vcol) | |||||
| { | { | ||||
| DRWSculptCallbackData scd = { | DRWSculptCallbackData scd = { | ||||
| .ob = ob, | .ob = ob, | ||||
| .shading_groups = &shgroup, | .shading_groups = &shgroup, | ||||
| .num_shading_groups = 1, | .num_shading_groups = 1, | ||||
| .use_wire = use_wire, | .use_wire = use_wire, | ||||
| .use_mats = false, | .use_mats = false, | ||||
| .use_mask = use_mask, | .use_mask = use_mask, | ||||
| }; | }; | ||||
| drw_sculpt_generate_calls(&scd, use_vcol); | drw_sculpt_generate_calls(&scd); | ||||
| } | } | ||||
| void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, | void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, | ||||
| int num_shgroups, | int num_shgroups, | ||||
| Object *ob, | Object *ob) | ||||
| bool use_vcol) | |||||
| { | { | ||||
| DRWSculptCallbackData scd = { | DRWSculptCallbackData scd = { | ||||
| .ob = ob, | .ob = ob, | ||||
| .shading_groups = shgroups, | .shading_groups = shgroups, | ||||
| .num_shading_groups = num_shgroups, | .num_shading_groups = num_shgroups, | ||||
| .use_wire = false, | .use_wire = false, | ||||
| .use_mats = true, | .use_mats = true, | ||||
| .use_mask = false, | .use_mask = false, | ||||
| }; | }; | ||||
| drw_sculpt_generate_calls(&scd, use_vcol); | drw_sculpt_generate_calls(&scd); | ||||
| } | } | ||||
| static GPUVertFormat inst_select_format = {0}; | static GPUVertFormat inst_select_format = {0}; | ||||
| DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, | DRWCallBuffer *DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, | ||||
| struct GPUVertFormat *format, | struct GPUVertFormat *format, | ||||
| GPUPrimType prim_type) | GPUPrimType prim_type) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 969 Lines • Show Last 20 Lines | |||||