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:
@@ -140,30 +140,27 @@ static void basic_cache_populate(void *vedata, Object *ob)
|
|||||||
{
|
{
|
||||||
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
|
||||||
|
|
||||||
if (!DRW_object_is_renderable(ob))
|
if (!DRW_object_is_renderable(ob)) {
|
||||||
return;
|
|
||||||
|
|
||||||
if (!DRW_check_particles_visible_within_active_context(ob)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DRWContextState *draw_ctx = DRW_context_state_get();
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
|
if (ob == draw_ctx->object_edit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ob != draw_ctx->object_edit) {
|
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
||||||
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
if (!psys_check_enabled(ob, psys, false)) {
|
||||||
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 (!DRW_check_psys_visible_within_active_context(ob, psys)) {
|
||||||
|
return;
|
||||||
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
|
}
|
||||||
draw_as = PART_DRAW_DOT;
|
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) {
|
||||||
if (draw_as == PART_DRAW_PATH) {
|
struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(psys, NULL);
|
||||||
struct Gwn_Batch *hairs = DRW_cache_particles_get_hair(psys, NULL);
|
DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
|
||||||
DRW_shgroup_call_add(stl->g_data->depth_shgrp, hairs, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -833,21 +833,15 @@ static void clay_cache_populate_particles(void *vedata, Object *ob)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DRW_check_particles_visible_within_active_context(ob)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
||||||
if (!psys_check_enabled(ob, psys, false)) {
|
if (!psys_check_enabled(ob, psys, false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ParticleSettings *part = psys->part;
|
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
|
||||||
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
return;
|
||||||
|
|
||||||
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
|
|
||||||
draw_as = PART_DRAW_DOT;
|
|
||||||
}
|
}
|
||||||
|
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) {
|
if (draw_as == PART_DRAW_PATH) {
|
||||||
struct Gwn_Batch *geom = DRW_cache_particles_get_hair(psys, NULL);
|
struct Gwn_Batch *geom = DRW_cache_particles_get_hair(psys, NULL);
|
||||||
DRWShadingGroup *hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl);
|
DRWShadingGroup *hair_shgrp = CLAY_hair_shgrp_get(vedata, ob, stl, psl);
|
||||||
|
|||||||
@@ -1472,7 +1472,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ob->type == OB_MESH) {
|
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;
|
material_hash = stl->g_data->hair_material_hash;
|
||||||
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
|
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
|
||||||
if (md->type != eModifierType_ParticleSystem) {
|
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)) {
|
if (!psys_check_enabled(ob, psys, false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ParticleSettings *part = psys->part;
|
ParticleSettings *part = psys->part;
|
||||||
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
const 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)) {
|
if (draw_as != PART_DRAW_PATH) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys, md);
|
struct Gwn_Batch *hair_geom = DRW_cache_particles_get_hair(psys, md);
|
||||||
|
|||||||
@@ -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)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
|
for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
|
||||||
if (!psys_check_enabled(ob, psys, false)) {
|
if (!psys_check_enabled(ob, psys, false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ParticleSettings *part = psys->part;
|
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
|
||||||
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
return;
|
||||||
|
|
||||||
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
|
|
||||||
draw_as = PART_DRAW_DOT;
|
|
||||||
}
|
}
|
||||||
|
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];
|
static float mat[4][4];
|
||||||
unit_m4(mat);
|
unit_m4(mat);
|
||||||
|
|||||||
@@ -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_mode_shade(const struct Object *ob);
|
||||||
int DRW_object_is_paint_mode(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 */
|
/* Draw commands */
|
||||||
void DRW_draw_pass(DRWPass *pass);
|
void DRW_draw_pass(DRWPass *pass);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_mesh.h"
|
#include "BKE_mesh.h"
|
||||||
#include "BKE_object.h"
|
#include "BKE_object.h"
|
||||||
|
#include "BKE_particle.h"
|
||||||
|
#include "BKE_pointcache.h"
|
||||||
#include "BKE_workspace.h"
|
#include "BKE_workspace.h"
|
||||||
|
|
||||||
#include "draw_manager.h"
|
#include "draw_manager.h"
|
||||||
@@ -219,13 +221,20 @@ int DRW_object_is_paint_mode(const Object *ob)
|
|||||||
return false;
|
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();
|
const DRWContextState *draw_ctx = DRW_context_state_get();
|
||||||
if (object == draw_ctx->object_edit) {
|
if (object == draw_ctx->object_edit) {
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|||||||
@@ -1914,74 +1914,76 @@ static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewL
|
|||||||
static void OBJECT_cache_populate_particles(Object *ob,
|
static void OBJECT_cache_populate_particles(Object *ob,
|
||||||
OBJECT_PassList *psl)
|
OBJECT_PassList *psl)
|
||||||
{
|
{
|
||||||
if (!DRW_check_particles_visible_within_active_context(ob)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
|
||||||
if (psys_check_enabled(ob, psys, false)) {
|
if (!psys_check_enabled(ob, psys, false)) {
|
||||||
ParticleSettings *part = psys->part;
|
continue;
|
||||||
int draw_as = (part->draw_as == PART_DRAW_REND) ? part->ren_as : part->draw_as;
|
}
|
||||||
|
if (!DRW_check_psys_visible_within_active_context(ob, psys)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (draw_as == PART_DRAW_PATH && !psys->pathcache && !psys->childcache) {
|
ParticleSettings *part = psys->part;
|
||||||
draw_as = PART_DRAW_DOT;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static float mat[4][4];
|
||||||
|
unit_m4(mat);
|
||||||
|
|
||||||
|
if (draw_as != PART_DRAW_PATH) {
|
||||||
|
struct Gwn_Batch *geom = DRW_cache_particles_get_dots(ob, psys);
|
||||||
|
DRWShadingGroup *shgrp = NULL;
|
||||||
|
static int screen_space[2] = {0, 1};
|
||||||
|
static float def_prim_col[3] = {0.5f, 0.5f, 0.5f};
|
||||||
|
static float def_sec_col[3] = {1.0f, 1.0f, 1.0f};
|
||||||
|
|
||||||
|
/* Dummy particle format for instancing to work. */
|
||||||
|
DRW_shgroup_instance_format(e_data.particle_format, {{"dummy", DRW_ATTRIB_FLOAT, 1}});
|
||||||
|
|
||||||
|
Material *ma = give_current_material(ob, part->omat);
|
||||||
|
|
||||||
|
switch (draw_as) {
|
||||||
|
case PART_DRAW_DOT:
|
||||||
|
shgrp = DRW_shgroup_create(e_data.part_dot_sh, psl->particle);
|
||||||
|
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
||||||
|
DRW_shgroup_uniform_vec3(shgrp, "outlineColor", ma ? &ma->specr : def_sec_col, 1);
|
||||||
|
DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
|
||||||
|
DRW_shgroup_uniform_float(shgrp, "size", &part->draw_size, 1);
|
||||||
|
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
||||||
|
DRW_shgroup_call_add(shgrp, geom, mat);
|
||||||
|
break;
|
||||||
|
case PART_DRAW_CROSS:
|
||||||
|
shgrp = DRW_shgroup_instance_create(
|
||||||
|
e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS),
|
||||||
|
e_data.particle_format);
|
||||||
|
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
||||||
|
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
||||||
|
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
|
||||||
|
break;
|
||||||
|
case PART_DRAW_CIRC:
|
||||||
|
shgrp = DRW_shgroup_instance_create(
|
||||||
|
e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC),
|
||||||
|
e_data.particle_format);
|
||||||
|
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
||||||
|
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
||||||
|
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[1], 1);
|
||||||
|
break;
|
||||||
|
case PART_DRAW_AXIS:
|
||||||
|
shgrp = DRW_shgroup_instance_create(
|
||||||
|
e_data.part_axis_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS),
|
||||||
|
e_data.particle_format);
|
||||||
|
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float mat[4][4];
|
if (shgrp) {
|
||||||
unit_m4(mat);
|
if (draw_as != PART_DRAW_DOT) {
|
||||||
|
DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
|
||||||
if (draw_as != PART_DRAW_PATH) {
|
DRW_shgroup_instance_batch(shgrp, geom);
|
||||||
struct Gwn_Batch *geom = DRW_cache_particles_get_dots(ob, psys);
|
|
||||||
DRWShadingGroup *shgrp = NULL;
|
|
||||||
static int screen_space[2] = {0, 1};
|
|
||||||
static float def_prim_col[3] = {0.5f, 0.5f, 0.5f};
|
|
||||||
static float def_sec_col[3] = {1.0f, 1.0f, 1.0f};
|
|
||||||
|
|
||||||
/* Dummy particle format for instancing to work. */
|
|
||||||
DRW_shgroup_instance_format(e_data.particle_format, {{"dummy", DRW_ATTRIB_FLOAT, 1}});
|
|
||||||
|
|
||||||
Material *ma = give_current_material(ob, part->omat);
|
|
||||||
|
|
||||||
switch (draw_as) {
|
|
||||||
case PART_DRAW_DOT:
|
|
||||||
shgrp = DRW_shgroup_create(e_data.part_dot_sh, psl->particle);
|
|
||||||
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
|
||||||
DRW_shgroup_uniform_vec3(shgrp, "outlineColor", ma ? &ma->specr : def_sec_col, 1);
|
|
||||||
DRW_shgroup_uniform_float(shgrp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
|
|
||||||
DRW_shgroup_uniform_float(shgrp, "size", &part->draw_size, 1);
|
|
||||||
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
|
||||||
DRW_shgroup_call_add(shgrp, geom, mat);
|
|
||||||
break;
|
|
||||||
case PART_DRAW_CROSS:
|
|
||||||
shgrp = DRW_shgroup_instance_create(
|
|
||||||
e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CROSS),
|
|
||||||
e_data.particle_format);
|
|
||||||
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
|
||||||
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
|
||||||
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
|
|
||||||
break;
|
|
||||||
case PART_DRAW_CIRC:
|
|
||||||
shgrp = DRW_shgroup_instance_create(
|
|
||||||
e_data.part_prim_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_CIRC),
|
|
||||||
e_data.particle_format);
|
|
||||||
DRW_shgroup_uniform_texture(shgrp, "ramp", globals_ramp);
|
|
||||||
DRW_shgroup_uniform_vec3(shgrp, "color", ma ? &ma->r : def_prim_col, 1);
|
|
||||||
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[1], 1);
|
|
||||||
break;
|
|
||||||
case PART_DRAW_AXIS:
|
|
||||||
shgrp = DRW_shgroup_instance_create(
|
|
||||||
e_data.part_axis_sh, psl->particle, DRW_cache_particles_get_prim(PART_DRAW_AXIS),
|
|
||||||
e_data.particle_format);
|
|
||||||
DRW_shgroup_uniform_int(shgrp, "screen_space", &screen_space[0], 1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shgrp) {
|
|
||||||
if (draw_as != PART_DRAW_DOT) {
|
|
||||||
DRW_shgroup_uniform_float(shgrp, "draw_size", &part->draw_size, 1);
|
|
||||||
DRW_shgroup_instance_batch(shgrp, geom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user