Particle edit: Make visibility check to be per-particle system

This way we can see other particle systems while combing another one.
This commit is contained in:
2018-05-15 11:35:39 +02:00
parent f25be56bc7
commit 361bc2bc50
7 changed files with 110 additions and 105 deletions

View File

@@ -140,32 +140,29 @@ static void basic_cache_populate(void *vedata, Object *ob)
{
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
if (!DRW_object_is_renderable(ob))
return;
if (!DRW_check_particles_visible_within_active_context(ob)) {
if (!DRW_object_is_renderable(ob)) {
return;
}
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob != draw_ctx->object_edit) {
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (psys_check_enabled(ob, psys, false)) {
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
draw_as = PART_DRAW_DOT;
if (ob == draw_ctx->object_edit) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
return;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH) {
struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(psys, NULL);
DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
}
}
}
}
struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {

View File

@@ -833,21 +833,15 @@ static void clay_cache_populate_particles(void *vedata, Object *ob)
return;
}
if (!DRW_check_particles_visible_within_active_context(ob)) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
draw_as = PART_DRAW_DOT;
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
return;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH) {
struct Gwn_Batch *geom = DRW_cache_particles_get_hair(psys, NULL);
DRWShadingGroup *hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl);

View File

@@ -1472,7 +1472,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
}
if (ob->type == OB_MESH) {
if (DRW_check_particles_visible_within_active_context(ob)) {
if (ob != draw_ctx->object_edit) {
material_hash = stl->g_data->hair_material_hash;
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type != eModifierType_ParticleSystem) {
@@ -1482,9 +1482,12 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
continue;
}
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as != PART_DRAW_PATH || (psys->pathcache == NULL && psys->childcache == NULL)) {
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as != PART_DRAW_PATH) {
continue;
}
struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys, md);

View File

@@ -488,19 +488,19 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *ob)
{
if (!DRW_check_particles_visible_within_active_context(ob)) {
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob == draw_ctx->object_edit) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
draw_as = PART_DRAW_DOT;
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
return;
}
ParticleSettings *part = psys->part;
const int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
static float mat[4][4];
unit_m4(mat);

View File

@@ -451,7 +451,7 @@ bool DRW_object_is_flat_normal(const struct Object *ob);
int DRW_object_is_mode_shade(const struct Object *ob);
int DRW_object_is_paint_mode(const struct Object *ob);
bool DRW_check_particles_visible_within_active_context(struct Object *object);
bool DRW_check_psys_visible_within_active_context(struct Object *object, struct ParticleSystem *psys);
/* Draw commands */
void DRW_draw_pass(DRWPass *pass);

View File

@@ -36,6 +36,8 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_workspace.h"
#include "draw_manager.h"
@@ -219,13 +221,20 @@ int DRW_object_is_paint_mode(const Object *ob)
return false;
}
bool DRW_check_particles_visible_within_active_context(Object *object)
bool DRW_check_psys_visible_within_active_context(
Object *object,
struct ParticleSystem *psys)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
if (object == draw_ctx->object_edit) {
return false;
}
return (object->mode != OB_MODE_PARTICLE_EDIT);
if (object->mode == OB_MODE_PARTICLE_EDIT) {
if (psys_in_edit_mode(draw_ctx->depsgraph, psys)) {
return false;
}
}
return true;
}
/** \} */

View File

@@ -1914,11 +1914,14 @@ static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewL
static void OBJECT_cache_populate_particles(Object *ob,
OBJECT_PassList *psl)
{
if (!DRW_check_particles_visible_within_active_context(ob)) {
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (!psys_check_enabled(ob, psys, false)) {
continue;
}
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
if (psys_check_enabled(ob, psys, false)) {
ParticleSettings *part = psys->part;
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
@@ -1985,7 +1988,6 @@ static void OBJECT_cache_populate_particles(Object *ob,
}
}
}
}
}
static void OBJECT_cache_populate(void *vedata, Object *ob)