diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-06-17 07:32:49 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-06-17 07:32:49 -0300 |
commit | e11fae0bbf08377cae2a250f3c4766c21dfb22e5 (patch) | |
tree | 4f58f52156ddf5110fba79175483842881b65e86 /servers | |
parent | 5fc3a9956eedcc421dd4435c10641f678a73815a (diff) |
Particles properly update the shadow maps, closes #8815
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_scene.cpp | 30 |
2 files changed, 33 insertions, 0 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 44cfbf74ce..75434c5fc5 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -465,6 +465,9 @@ public: virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; + virtual int particles_get_draw_passes(RID p_particles) const = 0; + virtual RID particles_get_draw_pass_mesh(RID p_particles, int p_pass) const = 0; + /* RENDER TARGET */ enum RenderTargetFlags { diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 352daa9655..6d1f698a5c 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -3323,6 +3323,36 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) { } else { can_cast_shadows = false; } + } else if (p_instance->base_type == VS::INSTANCE_PARTICLES) { + + bool cast_shadows = false; + + int dp = VSG::storage->particles_get_draw_passes(p_instance->base); + + for (int i = 0; i < dp; i++) { + + RID mesh = VSG::storage->particles_get_draw_pass_mesh(p_instance->base, i); + + int sc = VSG::storage->mesh_get_surface_count(mesh); + for (int j = 0; j < sc; j++) { + + RID mat = VSG::storage->mesh_surface_get_material(mesh, j); + + if (!mat.is_valid()) { + cast_shadows = true; + break; + } + + if (VSG::storage->material_casts_shadows(mat)) { + cast_shadows = true; + break; + } + } + } + + if (!cast_shadows) { + can_cast_shadows = false; + } } } |