Draw manager: Add utility function to check whether particle systems are to be drawn

This commit is contained in:
Sergey Sharybin 2018-05-09 16:55:09 +02:00
parent bac9b04778
commit 327789eaf8
7 changed files with 30 additions and 5 deletions

View File

@ -143,6 +143,10 @@ static void basic_cache_populate(void *vedata, Object *ob)
if (!DRW_object_is_renderable(ob))
return;
if (!DRW_check_particles_visible_within_active_context(ob)) {
return;
}
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob != draw_ctx->object_edit) {

View File

@ -833,6 +833,10 @@ 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;

View File

@ -1472,7 +1472,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
}
if (ob->type == OB_MESH) {
if (ob != draw_ctx->object_edit) {
if (DRW_check_particles_visible_within_active_context(ob)) {
material_hash = stl->g_data->hair_material_hash;
for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
if (md->type != eModifierType_ParticleSystem) {

View File

@ -452,11 +452,9 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
static void workbench_cache_populate_particles(WORKBENCH_Data *vedata, Object *ob)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
if (ob == draw_ctx->object_edit) {
if (!DRW_check_particles_visible_within_active_context(ob)) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) {
if (!psys_check_enabled(ob, psys, false)) {
continue;

View File

@ -73,6 +73,7 @@ struct DefaultFramebufferList;
struct DefaultTextureList;
struct DRWTextStore;
struct LampEngineData;
struct ParticleSystem;
struct RenderEngineType;
struct ViewportEngineData;
struct ViewportEngineData_Info;
@ -447,6 +448,9 @@ 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 ParticleSystem *psys);
/* Draw commands */
void DRW_draw_pass(DRWPass *pass);
void DRW_draw_pass_subset(DRWPass *pass, DRWShadingGroup *start_group, DRWShadingGroup *end_group);

View File

@ -45,6 +45,7 @@
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_particle.h"
#include "ED_view3d.h"
#include "GPU_draw.h"
@ -218,6 +219,20 @@ int DRW_object_is_paint_mode(const Object *ob)
return false;
}
bool DRW_check_particles_visible_within_active_context(Object *object)
{
const DRWContextState *draw_ctx = DRW_context_state_get();
if (object == draw_ctx->object_edit) {
return false;
}
return (object->mode != OB_MODE_PARTICLE_EDIT);
}
bool DRW_check_psys_visible_within_active_context(struct ParticleSystem *psys)
{
return PE_get_current_from_psys(psys) == NULL;
}
/** \} */

View File

@ -1914,7 +1914,7 @@ static void DRW_shgroup_object_center(OBJECT_StorageList *stl, Object *ob, ViewL
static void OBJECT_cache_populate_particles(Object *ob,
OBJECT_PassList *psl)
{
if (ob->mode == OB_MODE_PARTICLE_EDIT) {
if (!DRW_check_particles_visible_within_active_context(ob)) {
return;
}
for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {