Cleaned up and fixed the base_changed function in rasterizers, also fixes #15617

This commit is contained in:
Juan Linietsky 2018-11-14 09:32:39 -03:00
parent 37c5aa1084
commit 984063cf0b
10 changed files with 129 additions and 129 deletions

View File

@ -584,22 +584,12 @@ public:
SelfList<RasterizerScene::InstanceBase>::List instance_list;
_FORCE_INLINE_ void instance_change_notify() {
_FORCE_INLINE_ void instance_change_notify(bool p_aabb = true, bool p_materials = true) {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_changed();
instances = instances->next();
}
}
_FORCE_INLINE_ void instance_material_change_notify() {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_material_changed();
instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
}

View File

@ -1623,7 +1623,7 @@ void RasterizerStorageGLES2::_update_material(Material *p_material) {
}
for (Map<RasterizerScene::InstanceBase *, int>::Element *E = p_material->instance_owners.front(); E; E = E->next()) {
E->key()->base_material_changed();
E->key()->base_changed(false, true);
}
}
}
@ -2010,7 +2010,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
mesh->surfaces.push_back(surface);
mesh->instance_change_notify();
mesh->instance_change_notify(true, false);
info.vertex_mem += surface->total_data_size;
}
@ -2080,7 +2080,7 @@ void RasterizerStorageGLES2::mesh_surface_set_material(RID p_mesh, int p_surface
_material_add_geometry(mesh->surfaces[p_surface]->material, mesh->surfaces[p_surface]);
}
mesh->instance_material_change_notify();
mesh->instance_change_notify(false, true);
}
RID RasterizerStorageGLES2::mesh_surface_get_material(RID p_mesh, int p_surface) const {
@ -2188,13 +2188,11 @@ void RasterizerStorageGLES2::mesh_remove_surface(RID p_mesh, int p_surface) {
info.vertex_mem -= surface->total_data_size;
mesh->instance_material_change_notify();
memdelete(surface);
mesh->surfaces.remove(p_surface);
mesh->instance_change_notify();
mesh->instance_change_notify(true, true);
}
int RasterizerStorageGLES2::mesh_get_surface_count(RID p_mesh) const {
@ -2768,7 +2766,7 @@ void RasterizerStorageGLES2::update_dirty_multimeshes() {
multimesh->dirty_aabb = false;
multimesh->dirty_data = false;
multimesh->instance_change_notify();
multimesh->instance_change_notify(true, false);
multimesh_update_list.remove(multimesh_update_list.first());
}
@ -2873,7 +2871,7 @@ void RasterizerStorageGLES2::immediate_end(RID p_immediate) {
ERR_FAIL_COND(!im->building);
im->building = false;
im->instance_change_notify();
im->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::immediate_clear(RID p_immediate) {
@ -2882,7 +2880,7 @@ void RasterizerStorageGLES2::immediate_clear(RID p_immediate) {
ERR_FAIL_COND(im->building);
im->chunks.clear();
im->instance_change_notify();
im->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES2::immediate_get_aabb(RID p_immediate) const {
@ -2896,7 +2894,7 @@ void RasterizerStorageGLES2::immediate_set_material(RID p_immediate, RID p_mater
ERR_FAIL_COND(!im);
im->material = p_material;
im->instance_material_change_notify();
im->instance_change_notify(false, true);
}
RID RasterizerStorageGLES2::immediate_get_material(RID p_immediate) const {
@ -3107,7 +3105,7 @@ void RasterizerStorageGLES2::update_dirty_skeletons() {
}
for (Set<RasterizerScene::InstanceBase *>::Element *E = skeleton->instances.front(); E; E = E->next()) {
E->get()->base_changed();
E->get()->base_changed(true, false);
}
skeleton_update_list.remove(skeleton_update_list.first());
@ -3172,7 +3170,7 @@ void RasterizerStorageGLES2::light_set_param(RID p_light, VS::LightParam p_param
case VS::LIGHT_PARAM_SHADOW_NORMAL_BIAS:
case VS::LIGHT_PARAM_SHADOW_BIAS: {
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
} break;
default: {}
}
@ -3187,7 +3185,7 @@ void RasterizerStorageGLES2::light_set_shadow(RID p_light, bool p_enabled) {
light->shadow = p_enabled;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::light_set_shadow_color(RID p_light, const Color &p_color) {
@ -3218,7 +3216,7 @@ void RasterizerStorageGLES2::light_set_cull_mask(RID p_light, uint32_t p_mask) {
light->cull_mask = p_mask;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
@ -3228,7 +3226,7 @@ void RasterizerStorageGLES2::light_set_reverse_cull_face_mode(RID p_light, bool
light->reverse_cull = p_enabled;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {
@ -3238,7 +3236,7 @@ void RasterizerStorageGLES2::light_omni_set_shadow_mode(RID p_light, VS::LightOm
light->omni_shadow_mode = p_mode;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
VS::LightOmniShadowMode RasterizerStorageGLES2::light_omni_get_shadow_mode(RID p_light) {
@ -3255,7 +3253,7 @@ void RasterizerStorageGLES2::light_omni_set_shadow_detail(RID p_light, VS::Light
light->omni_shadow_detail = p_detail;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {
@ -3265,7 +3263,7 @@ void RasterizerStorageGLES2::light_directional_set_shadow_mode(RID p_light, VS::
light->directional_shadow_mode = p_mode;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::light_directional_set_blend_splits(RID p_light, bool p_enable) {
@ -3275,7 +3273,7 @@ void RasterizerStorageGLES2::light_directional_set_blend_splits(RID p_light, boo
light->directional_blend_splits = p_enable;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
bool RasterizerStorageGLES2::light_directional_get_blend_splits(RID p_light) const {
@ -3394,7 +3392,7 @@ void RasterizerStorageGLES2::reflection_probe_set_update_mode(RID p_probe, VS::R
ERR_FAIL_COND(!reflection_probe);
reflection_probe->update_mode = p_mode;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
@ -3435,7 +3433,7 @@ void RasterizerStorageGLES2::reflection_probe_set_max_distance(RID p_probe, floa
ERR_FAIL_COND(!reflection_probe);
reflection_probe->max_distance = p_distance;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
@ -3443,7 +3441,7 @@ void RasterizerStorageGLES2::reflection_probe_set_extents(RID p_probe, const Vec
ERR_FAIL_COND(!reflection_probe);
reflection_probe->extents = p_extents;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
@ -3451,7 +3449,7 @@ void RasterizerStorageGLES2::reflection_probe_set_origin_offset(RID p_probe, con
ERR_FAIL_COND(!reflection_probe);
reflection_probe->origin_offset = p_offset;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
@ -3475,7 +3473,7 @@ void RasterizerStorageGLES2::reflection_probe_set_enable_shadows(RID p_probe, bo
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
@ -3483,7 +3481,7 @@ void RasterizerStorageGLES2::reflection_probe_set_cull_mask(RID p_probe, uint32_
ERR_FAIL_COND(!reflection_probe);
reflection_probe->cull_mask = p_layers;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES2::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
@ -3667,7 +3665,7 @@ void RasterizerStorageGLES2::lightmap_capture_set_bounds(RID p_capture, const AA
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->bounds = p_bounds;
capture->instance_change_notify();
capture->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES2::lightmap_capture_get_bounds(RID p_capture) const {
@ -3688,7 +3686,7 @@ void RasterizerStorageGLES2::lightmap_capture_set_octree(RID p_capture, const Po
PoolVector<uint8_t>::Read r = p_octree.read();
copymem(w.ptr(), r.ptr(), p_octree.size());
}
capture->instance_change_notify();
capture->instance_change_notify(true, false);
}
PoolVector<uint8_t> RasterizerStorageGLES2::lightmap_capture_get_octree(RID p_capture) const {

View File

@ -150,20 +150,12 @@ public:
struct Instantiable : public RID_Data {
SelfList<RasterizerScene::InstanceBase>::List instance_list;
_FORCE_INLINE_ void instance_change_notify() {
_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_changed();
instances = instances->next();
}
}
_FORCE_INLINE_ void instance_material_change_notify() {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_material_changed();
instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
}
@ -661,7 +653,7 @@ public:
SelfList<MultiMesh> *mm = multimeshes.first();
while (mm) {
mm->self()->instance_material_change_notify();
mm->self()->instance_change_notify(false, true);
mm = mm->next();
}
}

View File

@ -361,6 +361,7 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener
for (int i = 0; i < snode->functions.size(); i++) {
SL::FunctionNode *fnode = snode->functions[i].function;
current_func_name = fnode->name;
function_code[fnode->name] = _dump_node_code(fnode->body, 1, r_gen_code, p_actions, p_default_actions, p_assigning);
}

View File

@ -2851,7 +2851,7 @@ void RasterizerStorageGLES3::_update_material(Material *material) {
}
for (Map<RasterizerScene::InstanceBase *, int>::Element *E = material->instance_owners.front(); E; E = E->next()) {
E->key()->base_material_changed();
E->key()->base_changed(false, true);
}
}
}
@ -3477,7 +3477,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS:
}
mesh->surfaces.push_back(surface);
mesh->instance_change_notify();
mesh->instance_change_notify(true, false);
info.vertex_mem += surface->total_data_size;
}
@ -3550,7 +3550,7 @@ void RasterizerStorageGLES3::mesh_surface_set_material(RID p_mesh, int p_surface
_material_add_geometry(mesh->surfaces[p_surface]->material, mesh->surfaces[p_surface]);
}
mesh->instance_material_change_notify();
mesh->instance_change_notify(false, true);
}
RID RasterizerStorageGLES3::mesh_surface_get_material(RID p_mesh, int p_surface) const {
@ -3746,13 +3746,11 @@ void RasterizerStorageGLES3::mesh_remove_surface(RID p_mesh, int p_surface) {
info.vertex_mem -= surface->total_data_size;
mesh->instance_material_change_notify();
memdelete(surface);
mesh->surfaces.remove(p_surface);
mesh->instance_change_notify();
mesh->instance_change_notify(true, true);
}
int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const {
@ -3768,7 +3766,7 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb
ERR_FAIL_COND(!mesh);
mesh->custom_aabb = p_aabb;
mesh->instance_change_notify();
mesh->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
@ -4667,7 +4665,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() {
multimesh->dirty_aabb = false;
multimesh->dirty_data = false;
multimesh->instance_change_notify();
multimesh->instance_change_notify(true, false);
multimesh_update_list.remove(multimesh_update_list.first());
}
@ -4778,7 +4776,7 @@ void RasterizerStorageGLES3::immediate_end(RID p_immediate) {
im->building = false;
im->instance_change_notify();
im->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
@ -4787,7 +4785,7 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
ERR_FAIL_COND(im->building);
im->chunks.clear();
im->instance_change_notify();
im->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
@ -4802,7 +4800,7 @@ void RasterizerStorageGLES3::immediate_set_material(RID p_immediate, RID p_mater
Immediate *im = immediate_owner.get(p_immediate);
ERR_FAIL_COND(!im);
im->material = p_material;
im->instance_material_change_notify();
im->instance_change_notify(false, true);
}
RID RasterizerStorageGLES3::immediate_get_material(RID p_immediate) const {
@ -5008,7 +5006,7 @@ void RasterizerStorageGLES3::update_dirty_skeletons() {
}
for (Set<RasterizerScene::InstanceBase *>::Element *E = skeleton->instances.front(); E; E = E->next()) {
E->get()->base_changed();
E->get()->base_changed(true, false);
}
skeleton_update_list.remove(skeleton_update_list.first());
@ -5074,7 +5072,7 @@ void RasterizerStorageGLES3::light_set_param(RID p_light, VS::LightParam p_param
case VS::LIGHT_PARAM_SHADOW_BIAS: {
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
} break;
default: {}
}
@ -5088,7 +5086,7 @@ void RasterizerStorageGLES3::light_set_shadow(RID p_light, bool p_enabled) {
light->shadow = p_enabled;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::light_set_shadow_color(RID p_light, const Color &p_color) {
@ -5121,7 +5119,7 @@ void RasterizerStorageGLES3::light_set_cull_mask(RID p_light, uint32_t p_mask) {
light->cull_mask = p_mask;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
@ -5132,7 +5130,7 @@ void RasterizerStorageGLES3::light_set_reverse_cull_face_mode(RID p_light, bool
light->reverse_cull = p_enabled;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {
@ -5143,7 +5141,7 @@ void RasterizerStorageGLES3::light_omni_set_shadow_mode(RID p_light, VS::LightOm
light->omni_shadow_mode = p_mode;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
VS::LightOmniShadowMode RasterizerStorageGLES3::light_omni_get_shadow_mode(RID p_light) {
@ -5161,7 +5159,7 @@ void RasterizerStorageGLES3::light_omni_set_shadow_detail(RID p_light, VS::Light
light->omni_shadow_detail = p_detail;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::light_directional_set_shadow_mode(RID p_light, VS::LightDirectionalShadowMode p_mode) {
@ -5171,7 +5169,7 @@ void RasterizerStorageGLES3::light_directional_set_shadow_mode(RID p_light, VS::
light->directional_shadow_mode = p_mode;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::light_directional_set_blend_splits(RID p_light, bool p_enable) {
@ -5181,7 +5179,7 @@ void RasterizerStorageGLES3::light_directional_set_blend_splits(RID p_light, boo
light->directional_blend_splits = p_enable;
light->version++;
light->instance_change_notify();
light->instance_change_notify(true, false);
}
bool RasterizerStorageGLES3::light_directional_get_blend_splits(RID p_light) const {
@ -5312,7 +5310,7 @@ void RasterizerStorageGLES3::reflection_probe_set_update_mode(RID p_probe, VS::R
ERR_FAIL_COND(!reflection_probe);
reflection_probe->update_mode = p_mode;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_intensity(RID p_probe, float p_intensity) {
@ -5353,7 +5351,7 @@ void RasterizerStorageGLES3::reflection_probe_set_max_distance(RID p_probe, floa
ERR_FAIL_COND(!reflection_probe);
reflection_probe->max_distance = p_distance;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_extents(RID p_probe, const Vector3 &p_extents) {
@ -5361,7 +5359,7 @@ void RasterizerStorageGLES3::reflection_probe_set_extents(RID p_probe, const Vec
ERR_FAIL_COND(!reflection_probe);
reflection_probe->extents = p_extents;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_origin_offset(RID p_probe, const Vector3 &p_offset) {
@ -5369,7 +5367,7 @@ void RasterizerStorageGLES3::reflection_probe_set_origin_offset(RID p_probe, con
ERR_FAIL_COND(!reflection_probe);
reflection_probe->origin_offset = p_offset;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_as_interior(RID p_probe, bool p_enable) {
@ -5393,7 +5391,7 @@ void RasterizerStorageGLES3::reflection_probe_set_enable_shadows(RID p_probe, bo
ERR_FAIL_COND(!reflection_probe);
reflection_probe->enable_shadows = p_enable;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) {
@ -5401,7 +5399,7 @@ void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_
ERR_FAIL_COND(!reflection_probe);
reflection_probe->cull_mask = p_layers;
reflection_probe->instance_change_notify();
reflection_probe->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::reflection_probe_set_resolution(RID p_probe, int p_resolution) {
@ -5489,7 +5487,7 @@ void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const AABB &p_boun
gip->bounds = p_bounds;
gip->version++;
gip->instance_change_notify();
gip->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const {
@ -5506,7 +5504,7 @@ void RasterizerStorageGLES3::gi_probe_set_cell_size(RID p_probe, float p_size) {
gip->cell_size = p_size;
gip->version++;
gip->instance_change_notify();
gip->instance_change_notify(true, false);
}
float RasterizerStorageGLES3::gi_probe_get_cell_size(RID p_probe) const {
@ -5539,7 +5537,7 @@ void RasterizerStorageGLES3::gi_probe_set_dynamic_data(RID p_probe, const PoolVe
gip->dynamic_data = p_data;
gip->version++;
gip->instance_change_notify();
gip->instance_change_notify(true, false);
}
PoolVector<int> RasterizerStorageGLES3::gi_probe_get_dynamic_data(RID p_probe) const {
@ -5771,7 +5769,7 @@ void RasterizerStorageGLES3::lightmap_capture_set_bounds(RID p_capture, const AA
LightmapCapture *capture = lightmap_capture_data_owner.getornull(p_capture);
ERR_FAIL_COND(!capture);
capture->bounds = p_bounds;
capture->instance_change_notify();
capture->instance_change_notify(true, false);
}
AABB RasterizerStorageGLES3::lightmap_capture_get_bounds(RID p_capture) const {
@ -5792,7 +5790,7 @@ void RasterizerStorageGLES3::lightmap_capture_set_octree(RID p_capture, const Po
PoolVector<uint8_t>::Read r = p_octree.read();
copymem(w.ptr(), r.ptr(), p_octree.size());
}
capture->instance_change_notify();
capture->instance_change_notify(true, false);
}
PoolVector<uint8_t> RasterizerStorageGLES3::lightmap_capture_get_octree(RID p_capture) const {
@ -6015,7 +6013,7 @@ void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AA
ERR_FAIL_COND(!particles);
particles->custom_aabb = p_aabb;
_particles_update_histories(particles);
particles->instance_change_notify();
particles->instance_change_notify(true, false);
}
void RasterizerStorageGLES3::particles_set_speed_scale(RID p_particles, float p_scale) {
@ -6441,7 +6439,7 @@ void RasterizerStorageGLES3::update_particles() {
particles->particle_valid_histories[0] = true;
}
particles->instance_change_notify(); //make sure shadows are updated
particles->instance_change_notify(true, false); //make sure shadows are updated
}
glDisable(GL_RASTERIZER_DISCARD);

View File

@ -181,22 +181,12 @@ public:
SelfList<RasterizerScene::InstanceBase>::List instance_list;
_FORCE_INLINE_ void instance_change_notify() {
_FORCE_INLINE_ void instance_change_notify(bool p_aabb, bool p_materials) {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_changed();
instances = instances->next();
}
}
_FORCE_INLINE_ void instance_material_change_notify() {
SelfList<RasterizerScene::InstanceBase> *instances = instance_list.first();
while (instances) {
instances->self()->base_material_changed();
instances->self()->base_changed(p_aabb, p_materials);
instances = instances->next();
}
}
@ -665,7 +655,7 @@ public:
bool active;
virtual void material_changed_notify() {
mesh->instance_material_change_notify();
mesh->instance_change_notify(false, true);
mesh->update_multimeshes();
}
@ -713,7 +703,7 @@ public:
SelfList<MultiMesh> *mm = multimeshes.first();
while (mm) {
mm->self()->instance_material_change_notify();
mm->self()->instance_change_notify(false, true);
mm = mm->next();
}
}

View File

@ -477,6 +477,7 @@ String ShaderCompilerGLES3::_dump_node_code(SL::Node *p_node, int p_level, Gener
//code for functions
for (int i = 0; i < pnode->functions.size(); i++) {
SL::FunctionNode *fnode = pnode->functions[i].function;
current_func_name = fnode->name;
function_code[fnode->name] = _dump_node_code(fnode->body, p_level + 1, r_gen_code, p_actions, p_default_actions, p_assigning);
}

View File

@ -120,9 +120,7 @@ public:
Vector<Color> lightmap_capture_data; //in a array (12 values) to avoid wasting space if unused. Alpha is unused, but needed to send to shader
virtual void base_removed() = 0;
virtual void base_changed() = 0;
virtual void base_material_changed() = 0;
virtual void base_changed(bool p_aabb, bool p_materials) = 0;
InstanceBase() :
dependency_item(this) {

View File

@ -612,7 +612,7 @@ void VisualServerScene::instance_set_surface_material(RID p_instance, int p_surf
VSG::storage->material_remove_instance_owner(instance->materials[p_surface], instance);
}
instance->materials.write[p_surface] = p_material;
instance->base_material_changed();
instance->base_changed(false, true);
if (instance->materials[p_surface].is_valid()) {
VSG::storage->material_add_instance_owner(instance->materials[p_surface], instance);
@ -840,7 +840,7 @@ void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instanc
ERR_FAIL_COND(!instance);
instance->cast_shadows = p_shadow_casting_setting;
instance->base_material_changed(); // to actually compute if shadows are visible or not
instance->base_changed(false, true); // to actually compute if shadows are visible or not
}
void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
@ -851,7 +851,7 @@ void VisualServerScene::instance_geometry_set_material_override(RID p_instance,
VSG::storage->material_remove_instance_owner(instance->material_override, instance);
}
instance->material_override = p_material;
instance->base_material_changed();
instance->base_changed(false, true);
if (instance->material_override.is_valid()) {
VSG::storage->material_add_instance_owner(instance->material_override, instance);
@ -1264,13 +1264,15 @@ void VisualServerScene::_update_instance_lightmap_captures(Instance *p_instance)
}
}
void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) {
bool VisualServerScene::_light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario) {
InstanceLightData *light = static_cast<InstanceLightData *>(p_instance->base_data);
Transform light_transform = p_instance->transform;
light_transform.orthonormalize(); //scale does not count on lights
bool animated_material_found = false;
switch (VSG::storage->light_get_type(p_instance->base)) {
case VS::LIGHT_DIRECTIONAL: {
@ -1303,6 +1305,10 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
continue;
}
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
animated_material_found = true;
}
float max, min;
instance->transformed_aabb.project_range_in_plane(base, min, max);
@ -1558,6 +1564,10 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
} else {
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
animated_material_found = true;
}
instance->depth = near_plane.distance_to(instance->transform.origin);
instance->depth_layer = 0;
}
@ -1609,6 +1619,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
} else {
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
animated_material_found = true;
}
instance->depth = near_plane.distance_to(instance->transform.origin);
instance->depth_layer = 0;
}
@ -1645,6 +1658,9 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
SWAP(instance_shadow_cull_result[j], instance_shadow_cull_result[cull_count]);
j--;
} else {
if (static_cast<InstanceGeometryData *>(instance->base_data)->material_is_animated) {
animated_material_found = true;
}
instance->depth = near_plane.distance_to(instance->transform.origin);
instance->depth_layer = 0;
}
@ -1655,6 +1671,8 @@ void VisualServerScene::_light_instance_update_shadow(Instance *p_instance, cons
} break;
}
return animated_material_found;
}
void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
@ -2096,7 +2114,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
if (redraw) {
//must redraw!
_light_instance_update_shadow(ins, p_cam_transform, p_cam_projection, p_cam_orthogonal, p_shadow_atlas, scenario);
light->shadow_dirty = _light_instance_update_shadow(ins, p_cam_transform, p_cam_projection, p_cam_orthogonal, p_shadow_atlas, scenario);
}
}
}
@ -3244,11 +3262,13 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
InstanceGeometryData *geom = static_cast<InstanceGeometryData *>(p_instance->base_data);
bool can_cast_shadows = true;
bool is_animated = false;
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_OFF) {
can_cast_shadows = false;
} else if (p_instance->material_override.is_valid()) {
can_cast_shadows = VSG::storage->material_casts_shadows(p_instance->material_override);
is_animated = VSG::storage->material_is_animated(p_instance->material_override);
} else {
if (p_instance->base_type == VS::INSTANCE_MESH) {
@ -3263,12 +3283,15 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
if (!mat.is_valid()) {
cast_shadows = true;
break;
}
} else {
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
break;
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
if (VSG::storage->material_is_animated(mat)) {
is_animated = true;
}
}
}
@ -3290,12 +3313,15 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
if (!mat.is_valid()) {
cast_shadows = true;
break;
}
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
break;
} else {
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
if (VSG::storage->material_is_animated(mat)) {
is_animated = true;
}
}
}
@ -3312,6 +3338,10 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
} else {
can_cast_shadows = false;
}
if (mat.is_valid() && VSG::storage->material_is_animated(mat)) {
is_animated = true;
}
} else if (p_instance->base_type == VS::INSTANCE_PARTICLES) {
bool cast_shadows = false;
@ -3331,12 +3361,15 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
if (!mat.is_valid()) {
cast_shadows = true;
break;
}
} else {
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
break;
if (VSG::storage->material_casts_shadows(mat)) {
cast_shadows = true;
}
if (VSG::storage->material_is_animated(mat)) {
is_animated = true;
}
}
}
}
@ -3356,6 +3389,8 @@ void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
geom->can_cast_shadows = can_cast_shadows;
}
geom->material_is_animated = is_animated;
}
}

View File

@ -192,14 +192,9 @@ public:
singleton->instance_set_base(self, RID());
}
virtual void base_changed() {
virtual void base_changed(bool p_aabb, bool p_materials) {
singleton->_instance_queue_update(this, true, true);
}
virtual void base_material_changed() {
singleton->_instance_queue_update(this, false, true);
singleton->_instance_queue_update(this, p_aabb, p_materials);
}
Instance() :
@ -247,6 +242,7 @@ public:
List<Instance *> lighting;
bool lighting_dirty;
bool can_cast_shadows;
bool material_is_animated;
List<Instance *> reflection_probes;
bool reflection_dirty;
@ -261,6 +257,7 @@ public:
lighting_dirty = false;
reflection_dirty = true;
can_cast_shadows = true;
material_is_animated = true;
gi_probes_dirty = true;
}
};
@ -488,7 +485,7 @@ public:
_FORCE_INLINE_ void _update_dirty_instance(Instance *p_instance);
_FORCE_INLINE_ void _update_instance_lightmap_captures(Instance *p_instance);
_FORCE_INLINE_ void _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario);
_FORCE_INLINE_ bool _light_instance_update_shadow(Instance *p_instance, const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_shadow_atlas, Scenario *p_scenario);
void _prepare_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, uint32_t p_visible_layers, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe);
void _render_scene(const Transform p_cam_transform, const CameraMatrix &p_cam_projection, bool p_cam_orthogonal, RID p_force_environment, RID p_scenario, RID p_shadow_atlas, RID p_reflection_probe, int p_reflection_probe_pass);