summaryrefslogtreecommitdiff
path: root/scene/3d/visual_instance.cpp
diff options
context:
space:
mode:
authorSaracen <SaracenOne@gmail.com>2016-03-07 23:00:55 +0000
committerSaracen <SaracenOne@gmail.com>2016-03-07 23:14:14 +0000
commit7fecebd8a8dc12e59c8fd430b9e3dc0069fd48d1 (patch)
tree668b6cc2cc7787711d3384f2308684bf5fc68e44 /scene/3d/visual_instance.cpp
parent20308c0475acb4678c9b86c7a4f210c1ec7548dc (diff)
Added extra controls to GeometryInstances to control how they should cast shadows: double-sided and shadows only.
Conflicts: servers/visual/visual_server_raster.h
Diffstat (limited to 'scene/3d/visual_instance.cpp')
-rw-r--r--scene/3d/visual_instance.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 723b0a9af5..b15226cce3 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -267,6 +267,15 @@ void GeometryInstance::_update_visibility() {
void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
ERR_FAIL_INDEX(p_flag,FLAG_MAX);
+ if (p_flag==FLAG_CAST_SHADOW) {
+ if (p_value == true) {
+ set_cast_shadows_setting(SHADOW_CASTING_SETTING_ON);
+ }
+ else {
+ set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
+ }
+ }
+
if (flags[p_flag]==p_value)
return;
@@ -294,10 +303,32 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
bool GeometryInstance::get_flag(Flags p_flag) const{
ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+
+ if (p_flag == FLAG_CAST_SHADOW) {
+ if (shadow_casting_setting == SHADOW_CASTING_SETTING_OFF) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+
return flags[p_flag];
}
+void GeometryInstance::set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting) {
+
+ shadow_casting_setting = p_shadow_casting_setting;
+
+ VS::get_singleton()->instance_geometry_set_cast_shadows_setting(get_instance(), (VS::ShadowCastingSetting)p_shadow_casting_setting);
+}
+
+GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_setting() const {
+
+ return shadow_casting_setting;
+}
+
void GeometryInstance::set_baked_light_texture_id(int p_id) {
baked_light_texture_id=p_id;
@@ -330,6 +361,9 @@ void GeometryInstance::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_flag","flag","value"), &GeometryInstance::set_flag);
ObjectTypeDB::bind_method(_MD("get_flag","flag"), &GeometryInstance::get_flag);
+ ObjectTypeDB::bind_method(_MD("set_cast_shadows_setting", "shadow_casting_setting"), &GeometryInstance::set_cast_shadows_setting);
+ ObjectTypeDB::bind_method(_MD("get_cast_shadows_setting"), &GeometryInstance::get_cast_shadows_setting);
+
ObjectTypeDB::bind_method(_MD("set_draw_range_begin","mode"), &GeometryInstance::set_draw_range_begin);
ObjectTypeDB::bind_method(_MD("get_draw_range_begin"), &GeometryInstance::get_draw_range_begin);
@@ -346,7 +380,7 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE);
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "geometry/material_override",PROPERTY_HINT_RESOURCE_TYPE,"Material"), _SCS("set_material_override"), _SCS("get_material_override"));
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/cast_shadow"), _SCS("set_flag"), _SCS("get_flag"),FLAG_CAST_SHADOW);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "geometry/cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), _SCS("set_cast_shadows_setting"), _SCS("get_cast_shadows_setting"));
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/receive_shadows"), _SCS("set_flag"), _SCS("get_flag"),FLAG_RECEIVE_SHADOWS);
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_begin",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_begin"), _SCS("get_draw_range_begin"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/range_end",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_draw_range_end"), _SCS("get_draw_range_end"));
@@ -369,6 +403,11 @@ void GeometryInstance::_bind_methods() {
BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS );
BIND_CONSTANT(FLAG_MAX );
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_OFF);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_ON);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_DOUBLE_SIDED);
+ BIND_CONSTANT(SHADOW_CASTING_SETTING_SHADOWS_ONLY);
+
}
GeometryInstance::GeometryInstance() {
@@ -381,6 +420,7 @@ GeometryInstance::GeometryInstance() {
flags[FLAG_VISIBLE]=true;
flags[FLAG_CAST_SHADOW]=true;
flags[FLAG_RECEIVE_SHADOWS]=true;
+ shadow_casting_setting=SHADOW_CASTING_SETTING_ON;
baked_light_instance=NULL;
baked_light_texture_id=0;
extra_cull_margin=0;