Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_particle.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_particle.c.
| Show All 9 Lines | |||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "DNA_particle_types.h" | #include "DNA_particle_types.h" | ||||
| #include "BKE_pointcache.h" | #include "BKE_pointcache.h" | ||||
| #include "ED_particle.h" | #include "ED_particle.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Edit Particles | /** \name Edit Particles | ||||
| * \{ */ | * \{ */ | ||||
| void OVERLAY_edit_particle_cache_init(OVERLAY_Data *vedata) | void OVERLAY_edit_particle_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| Show All 32 Lines | void OVERLAY_edit_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| * create edit structure for until after next dependency graph evaluation. | * create edit structure for until after next dependency graph evaluation. | ||||
| * | * | ||||
| * Ideally, the edit structure will be created here already via some | * Ideally, the edit structure will be created here already via some | ||||
| * dependency graph callback or so, but currently trying to make it nicer | * dependency graph callback or so, but currently trying to make it nicer | ||||
| * only causes bad level calls and breaks design from the past. | * only causes bad level calls and breaks design from the past. | ||||
| */ | */ | ||||
| Object *ob_orig = DEG_get_original_object(ob); | Object *ob_orig = DEG_get_original_object(ob); | ||||
| PTCacheEdit *edit = PE_create_current(draw_ctx->depsgraph, scene_orig, ob_orig); | PTCacheEdit *edit = PE_create_current(draw_ctx->depsgraph, scene_orig, ob_orig); | ||||
| if (edit == NULL) { | if (edit == nullptr) { | ||||
| /* Happens when trying to edit particles in EMITTER mode without | /* Happens when trying to edit particles in EMITTER mode without | ||||
| * having them cached. | * having them cached. | ||||
| */ | */ | ||||
| return; | return; | ||||
| } | } | ||||
| /* NOTE: We need to pass evaluated particle system, which we need | /* NOTE: We need to pass evaluated particle system, which we need | ||||
| * to find first. | * to find first. | ||||
| */ | */ | ||||
| ParticleSystem *psys = ob->particlesystem.first; | ParticleSystem *psys = static_cast<ParticleSystem *>(ob->particlesystem.first); | ||||
| LISTBASE_FOREACH (ParticleSystem *, psys_orig, &ob_orig->particlesystem) { | LISTBASE_FOREACH (ParticleSystem *, psys_orig, &ob_orig->particlesystem) { | ||||
| if (PE_get_current_from_psys(psys_orig) == edit) { | if (PE_get_current_from_psys(psys_orig) == edit) { | ||||
| break; | break; | ||||
| } | } | ||||
| psys = psys->next; | psys = psys->next; | ||||
| } | } | ||||
| if (psys == NULL) { | if (psys == nullptr) { | ||||
| printf("Error getting evaluated particle system for edit.\n"); | printf("Error getting evaluated particle system for edit.\n"); | ||||
| return; | return; | ||||
| } | } | ||||
| struct GPUBatch *geom; | struct GPUBatch *geom; | ||||
| { | { | ||||
| geom = DRW_cache_particles_get_edit_strands(ob, psys, edit, pd->edit_particle.use_weight); | geom = DRW_cache_particles_get_edit_strands(ob, psys, edit, pd->edit_particle.use_weight); | ||||
| DRW_shgroup_call(pd->edit_particle_strand_grp, geom, NULL); | DRW_shgroup_call(pd->edit_particle_strand_grp, geom, nullptr); | ||||
| } | } | ||||
| if (pd->edit_particle.select_mode == SCE_SELECT_POINT) { | if (pd->edit_particle.select_mode == SCE_SELECT_POINT) { | ||||
| geom = DRW_cache_particles_get_edit_inner_points(ob, psys, edit); | geom = DRW_cache_particles_get_edit_inner_points(ob, psys, edit); | ||||
| DRW_shgroup_call(pd->edit_particle_point_grp, geom, NULL); | DRW_shgroup_call(pd->edit_particle_point_grp, geom, nullptr); | ||||
| } | } | ||||
| if (ELEM(pd->edit_particle.select_mode, SCE_SELECT_POINT, SCE_SELECT_END)) { | if (ELEM(pd->edit_particle.select_mode, SCE_SELECT_POINT, SCE_SELECT_END)) { | ||||
| geom = DRW_cache_particles_get_edit_tip_points(ob, psys, edit); | geom = DRW_cache_particles_get_edit_tip_points(ob, psys, edit); | ||||
| DRW_shgroup_call(pd->edit_particle_point_grp, geom, NULL); | DRW_shgroup_call(pd->edit_particle_point_grp, geom, nullptr); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_edit_particle_draw(OVERLAY_Data *vedata) | void OVERLAY_edit_particle_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_FramebufferList *fbl = vedata->fbl; | OVERLAY_FramebufferList *fbl = vedata->fbl; | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { | ||||
| if (part->type == PART_HAIR) { | if (part->type == PART_HAIR) { | ||||
| /* Hairs should have been rendered by the render engine. */ | /* Hairs should have been rendered by the render engine. */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!ELEM(draw_as, PART_DRAW_NOT, PART_DRAW_OB, PART_DRAW_GR)) { | if (!ELEM(draw_as, PART_DRAW_NOT, PART_DRAW_OB, PART_DRAW_GR)) { | ||||
| struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys); | struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys); | ||||
| struct GPUBatch *shape = NULL; | struct GPUBatch *shape = nullptr; | ||||
| DRWShadingGroup *grp; | DRWShadingGroup *grp; | ||||
| /* TODO(fclem): Here would be a good place for preemptive culling. */ | /* TODO(fclem): Here would be a good place for preemptive culling. */ | ||||
| /* NOTE(fclem): Is color even useful in our modern context? */ | /* NOTE(fclem): Is color even useful in our modern context? */ | ||||
| Material *ma = BKE_object_material_get_eval(ob, part->omat); | Material *ma = BKE_object_material_get_eval(ob, part->omat); | ||||
| float color[4] = {0.6f, 0.6f, 0.6f, part->draw_size}; | float color[4] = {0.6f, 0.6f, 0.6f, part->draw_size}; | ||||
| if (ma != NULL) { | if (ma != nullptr) { | ||||
| copy_v3_v3(color, &ma->r); | copy_v3_v3(color, &ma->r); | ||||
| } | } | ||||
| switch (draw_as) { | switch (draw_as) { | ||||
| default: | default: | ||||
| case PART_DRAW_DOT: | case PART_DRAW_DOT: | ||||
| grp = DRW_shgroup_create_sub(pd->particle_dots_grp); | grp = DRW_shgroup_create_sub(pd->particle_dots_grp); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", color); | DRW_shgroup_uniform_vec4_copy(grp, "color", color); | ||||
| DRW_shgroup_call(grp, geom, NULL); | DRW_shgroup_call(grp, geom, nullptr); | ||||
| break; | break; | ||||
| case PART_DRAW_AXIS: | case PART_DRAW_AXIS: | ||||
| case PART_DRAW_CIRC: | case PART_DRAW_CIRC: | ||||
| case PART_DRAW_CROSS: | case PART_DRAW_CROSS: | ||||
| grp = DRW_shgroup_create_sub(pd->particle_shapes_grp); | grp = DRW_shgroup_create_sub(pd->particle_shapes_grp); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", color); | DRW_shgroup_uniform_vec4_copy(grp, "color", color); | ||||
| shape = DRW_cache_particles_get_prim(draw_as); | shape = DRW_cache_particles_get_prim(draw_as); | ||||
| DRW_shgroup_call_instances_with_attrs(grp, NULL, shape, geom); | DRW_shgroup_call_instances_with_attrs(grp, nullptr, shape, geom); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_particle_draw(OVERLAY_Data *vedata) | void OVERLAY_particle_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| DRW_draw_pass(psl->particle_ps); | DRW_draw_pass(psl->particle_ps); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||