summaryrefslogtreecommitdiff
path: root/servers/visual
diff options
context:
space:
mode:
Diffstat (limited to 'servers/visual')
-rw-r--r--servers/visual/rasterizer.h1
-rw-r--r--servers/visual/visual_server_raster.cpp48
-rw-r--r--servers/visual/visual_server_raster.h6
-rw-r--r--servers/visual/visual_server_wrap_mt.h3
4 files changed, 45 insertions, 13 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index b84e83cb0c..345c8bb32e 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -539,6 +539,7 @@ public:
Vector<RID> light_instances;
Vector<float> morph_values;
BakedLightData *baked_light;
+ VS::ShadowCastingSetting cast_shadows;
Transform *baked_light_octree_xform;
int baked_lightmap_id;
bool mirror :8;
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 3675194325..ec468b5e04 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -2724,7 +2724,12 @@ void VisualServerRaster::instance_geometry_set_flag(RID p_instance,InstanceFlags
} break;
case INSTANCE_FLAG_CAST_SHADOW: {
- instance->cast_shadows=p_enabled;
+ if (p_enabled == true) {
+ instance->data.cast_shadows = SHADOW_CASTING_SETTING_ON;
+ }
+ else {
+ instance->data.cast_shadows = SHADOW_CASTING_SETTING_OFF;
+ }
} break;
case INSTANCE_FLAG_RECEIVE_SHADOWS: {
@@ -2771,7 +2776,12 @@ bool VisualServerRaster::instance_geometry_get_flag(RID p_instance,InstanceFlags
} break;
case INSTANCE_FLAG_CAST_SHADOW: {
- return instance->cast_shadows;
+ if(instance->data.cast_shadows == SHADOW_CASTING_SETTING_OFF) {
+ return false;
+ }
+ else {
+ return true;
+ }
} break;
case INSTANCE_FLAG_RECEIVE_SHADOWS: {
@@ -2795,6 +2805,22 @@ bool VisualServerRaster::instance_geometry_get_flag(RID p_instance,InstanceFlags
return false;
}
+void VisualServerRaster::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
+
+ Instance *instance = instance_owner.get( p_instance );
+ ERR_FAIL_COND( !instance );
+
+ instance->data.cast_shadows = p_shadow_casting_setting;
+}
+
+VS::ShadowCastingSetting VisualServerRaster::instance_geometry_get_cast_shadows_setting(RID p_instance) const{
+
+ const Instance *instance = instance_owner.get( p_instance );
+ ERR_FAIL_COND_V( !instance, SHADOW_CASTING_SETTING_OFF );
+
+ return instance->data.cast_shadows;
+}
+
void VisualServerRaster::instance_geometry_set_material_override(RID p_instance, RID p_material) {
@@ -5019,7 +5045,7 @@ void VisualServerRaster::_light_instance_update_pssm_shadow(Instance *p_light,Sc
float min,max;
Instance *ins=instance_shadow_cull_result[j];
- if (!ins->visible || !ins->cast_shadows)
+ if (!ins->visible || ins->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
continue;
ins->transformed_aabb.project_range_in_plane(Plane(z_vec,0),min,max);
@@ -5047,7 +5073,7 @@ void VisualServerRaster::_light_instance_update_pssm_shadow(Instance *p_light,Sc
for (int j=0;j<caster_cull_count;j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !instance->cast_shadows)
+ if (!instance->visible || instance->data.cast_shadows==VS::SHADOW_CASTING_SETTING_OFF)
continue;
_instance_draw(instance);
}
@@ -5130,7 +5156,7 @@ void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,
for(int i=0;i<caster_count;i++) {
Instance *ins = instance_shadow_cull_result[i];
- if (!ins->visible || !ins->cast_shadows)
+ if (!ins->visible || ins->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
continue;
for(int j=0;j<8;j++) {
@@ -5281,7 +5307,7 @@ void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,
Instance *instance = instance_shadow_cull_result[i];
- if (!instance->visible || !instance->cast_shadows)
+ if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
continue;
_instance_draw(instance);
}
@@ -5378,7 +5404,7 @@ void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,
for(int i=0;i<caster_count;i++) {
Instance *ins=instance_shadow_cull_result[i];
- if (!ins->visible || !ins->cast_shadows)
+ if (!ins->visible || ins->cast_shadows==VS::SHADOW_CASTING_SETTING_OFF)
continue;
//@TODO optimize using support mapping
@@ -5468,7 +5494,7 @@ void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light,
Instance *instance = instance_shadow_cull_result[i];
- if (!instance->visible || !instance->cast_shadows)
+ if (!instance->visible || instance->cast_shadows==VS::SHADOW_CASTING_SETTING_OFF)
continue;
_instance_draw(instance);
}
@@ -5516,7 +5542,7 @@ void VisualServerRaster::_light_instance_update_shadow(Instance *p_light,Scenari
for (int i=0;i<cull_count;i++) {
Instance *instance = instance_shadow_cull_result[i];
- if (!instance->visible || !instance->cast_shadows)
+ if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
continue;
_instance_draw(instance);
}
@@ -5557,7 +5583,7 @@ void VisualServerRaster::_light_instance_update_shadow(Instance *p_light,Scenari
for (int j=0;j<cull_count;j++) {
Instance *instance = instance_shadow_cull_result[j];
- if (!instance->visible || !instance->cast_shadows)
+ if (!instance->visible || instance->data.cast_shadows == VS::SHADOW_CASTING_SETTING_OFF)
continue;
_instance_draw(instance);
@@ -6511,7 +6537,7 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S
}
}
- } else if ((1<<ins->base_type)&INSTANCE_GEOMETRY_MASK && ins->visible) {
+ } else if ((1<<ins->base_type)&INSTANCE_GEOMETRY_MASK && ins->visible && ins->data.cast_shadows!=VS::SHADOW_CASTING_SETTING_SHADOWS_ONLY) {
bool discarded=false;
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 459dc60e81..4456843c79 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -169,7 +169,6 @@ class VisualServerRaster : public VisualServer {
AABB transformed_aabb;
uint32_t object_ID;
bool visible;
- bool cast_shadows;
bool receive_shadows;
bool visible_in_all_rooms;
uint32_t layer_mask;
@@ -300,7 +299,7 @@ class VisualServerRaster : public VisualServer {
update_next=NULL;
update=false;
visible=true;
- cast_shadows=true;
+ data.cast_shadows=SHADOW_CASTING_SETTING_ON;
receive_shadows=true;
data.depth_scale=false;
data.billboard=false;
@@ -1093,6 +1092,9 @@ public:
virtual void instance_geometry_set_flag(RID p_instance,InstanceFlags p_flags,bool p_enabled);
virtual bool instance_geometry_get_flag(RID p_instance,InstanceFlags p_flags) const;
+ virtual void instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting);
+ virtual VS::ShadowCastingSetting instance_geometry_get_cast_shadows_setting(RID p_instance) const;
+
virtual void instance_geometry_set_material_override(RID p_instance, RID p_material);
virtual RID instance_geometry_get_material_override(RID p_instance) const;
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index fb502d8a6e..74630d67ef 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -534,6 +534,9 @@ public:
FUNC3(instance_geometry_set_flag,RID,InstanceFlags ,bool );
FUNC2RC(bool,instance_geometry_get_flag,RID,InstanceFlags );
+ FUNC2(instance_geometry_set_cast_shadows_setting, RID, ShadowCastingSetting);
+ FUNC1RC(ShadowCastingSetting, instance_geometry_get_cast_shadows_setting, RID);
+
FUNC2(instance_geometry_set_material_override,RID, RID );
FUNC1RC(RID,instance_geometry_get_material_override,RID);