summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-10-03 16:33:42 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-10-03 21:35:16 +0200
commit22d83bc9f655d5ae7a1b49709c4c1b663725daf5 (patch)
treea817195c08d4713a70ca014a3f63f5937934fe36 /scene
parent78d97b060a6873a454e710380cb9ef1bde5e4c65 (diff)
Begining of GLES3 renderer:
-Most 2D drawing is implemented -Missing shaders -Missing all 3D -Editor needs to be set on update always to be used, otherwise it does not refresh -Large parts of editor not working
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp151
-rw-r--r--scene/2d/canvas_item.h38
-rw-r--r--scene/2d/light_2d.cpp60
-rw-r--r--scene/2d/light_2d.h29
-rw-r--r--scene/2d/sprite.cpp3
-rw-r--r--scene/2d/sprite.h2
-rw-r--r--scene/2d/tile_map.cpp15
-rw-r--r--scene/3d/baked_light_instance.cpp2
-rw-r--r--scene/3d/baked_light_instance.h3
-rw-r--r--scene/3d/camera.cpp107
-rw-r--r--scene/3d/camera.h6
-rw-r--r--scene/3d/light.cpp509
-rw-r--r--scene/3d/light.h104
-rw-r--r--scene/3d/particles.cpp2
-rw-r--r--scene/3d/particles.h3
-rw-r--r--scene/3d/portal.cpp44
-rw-r--r--scene/3d/portal.h2
-rw-r--r--scene/3d/position_3d.cpp31
-rw-r--r--scene/3d/position_3d.h1
-rw-r--r--scene/3d/quad.cpp2
-rw-r--r--scene/3d/room_instance.cpp77
-rw-r--r--scene/3d/room_instance.h5
-rw-r--r--scene/3d/skeleton.cpp47
-rw-r--r--scene/3d/skeleton.h1
-rw-r--r--scene/3d/spatial_player.cpp140
-rw-r--r--scene/3d/spatial_player.h2
-rw-r--r--scene/3d/visual_instance.cpp108
-rw-r--r--scene/3d/visual_instance.h21
-rw-r--r--scene/gui/color_picker.cpp76
-rw-r--r--scene/gui/patch_9_frame.cpp2
-rw-r--r--scene/main/canvas_layer.cpp10
-rw-r--r--scene/main/canvas_layer.h5
-rw-r--r--scene/main/node.cpp10
-rw-r--r--scene/main/scene_main_loop.cpp35
-rw-r--r--scene/main/viewport.cpp260
-rw-r--r--scene/main/viewport.h74
-rw-r--r--scene/register_scene_types.cpp25
-rw-r--r--scene/resources/baked_light.cpp5
-rw-r--r--scene/resources/baked_light.h5
-rw-r--r--scene/resources/bit_mask.cpp7
-rw-r--r--scene/resources/default_theme/color_picker_hue.pngbin0 -> 132 bytes
-rw-r--r--scene/resources/default_theme/color_picker_main.pngbin0 -> 310 bytes
-rw-r--r--scene/resources/default_theme/color_picker_sample.pngbin0 -> 194 bytes
-rw-r--r--scene/resources/default_theme/default_theme.cpp18
-rw-r--r--scene/resources/default_theme/theme_data.h15
-rw-r--r--scene/resources/dynamic_font.cpp2
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/environment.cpp245
-rw-r--r--scene/resources/environment.h97
-rw-r--r--scene/resources/material.cpp552
-rw-r--r--scene/resources/material.h188
-rw-r--r--scene/resources/mesh.cpp38
-rw-r--r--scene/resources/mesh.h5
-rw-r--r--scene/resources/multimesh.cpp42
-rw-r--r--scene/resources/multimesh.h29
-rw-r--r--scene/resources/room.cpp38
-rw-r--r--scene/resources/room.h8
-rw-r--r--scene/resources/shader.cpp334
-rw-r--r--scene/resources/shader.h19
-rw-r--r--scene/resources/shader_graph.cpp7
-rw-r--r--scene/resources/shader_graph.h4
-rw-r--r--scene/resources/style_box.cpp126
-rw-r--r--scene/resources/style_box.h30
-rw-r--r--scene/resources/texture.cpp18
-rw-r--r--scene/resources/texture.h2
65 files changed, 677 insertions, 3171 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index ed1d606ba8..07ee1ff753 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -42,9 +42,6 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value)
if (p_name==SceneStringNames::get_singleton()->shader_shader) {
set_shader(p_value);
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
- set_shading_mode(ShadingMode(p_value.operator int()));
- return true;
} else {
if (shader.is_valid()) {
@@ -58,7 +55,7 @@ bool CanvasItemMaterial::_set(const StringName& p_name, const Variant& p_value)
}
}
if (pr) {
- VisualServer::get_singleton()->canvas_item_material_set_shader_param(material,pr,p_value);
+ VisualServer::get_singleton()->material_set_param(material,pr,p_value);
return true;
}
}
@@ -74,18 +71,14 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
r_ret=get_shader();
return true;
- } else if (p_name==SceneStringNames::get_singleton()->shading_mode) {
-
- r_ret=shading_mode;
- return true;
} else {
if (shader.is_valid()) {
StringName pr = shader->remap_param(p_name);
if (pr) {
- r_ret=VisualServer::get_singleton()->canvas_item_material_get_shader_param(material,pr);
+ r_ret=VisualServer::get_singleton()->material_get_param(material,pr);
return true;
}
}
@@ -100,7 +93,6 @@ bool CanvasItemMaterial::_get(const StringName& p_name,Variant &r_ret) const {
void CanvasItemMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"CanvasItemShader,CanvasItemShaderGraph" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "shader/shading_mode",PROPERTY_HINT_ENUM,"Normal,Unshaded,Light Only") );
if (!shader.is_null()) {
@@ -119,7 +111,7 @@ void CanvasItemMaterial::set_shader(const Ref<Shader>& p_shader) {
if (shader.is_valid())
rid=shader->get_rid();
- VS::get_singleton()->canvas_item_material_set_shader(material,rid);
+ VS::get_singleton()->material_set_shader(material,rid);
_change_notify(); //properties for shader exposed
emit_changed();
}
@@ -131,12 +123,12 @@ Ref<Shader> CanvasItemMaterial::get_shader() const{
void CanvasItemMaterial::set_shader_param(const StringName& p_param,const Variant& p_value){
- VS::get_singleton()->canvas_item_material_set_shader_param(material,p_param,p_value);
+ VS::get_singleton()->material_set_param(material,p_param,p_value);
}
Variant CanvasItemMaterial::get_shader_param(const StringName& p_param) const{
- return VS::get_singleton()->canvas_item_material_get_shader_param(material,p_param);
+ return VS::get_singleton()->material_get_param(material,p_param);
}
RID CanvasItemMaterial::get_rid() const {
@@ -144,16 +136,6 @@ RID CanvasItemMaterial::get_rid() const {
return material;
}
-void CanvasItemMaterial::set_shading_mode(ShadingMode p_mode) {
-
- shading_mode=p_mode;
- VS::get_singleton()->canvas_item_material_set_shading_mode(material,VS::CanvasItemShadingMode(p_mode));
-}
-
-CanvasItemMaterial::ShadingMode CanvasItemMaterial::get_shading_mode() const {
- return shading_mode;
-}
-
void CanvasItemMaterial::_bind_methods() {
@@ -161,12 +143,7 @@ void CanvasItemMaterial::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_shader:Shader"),&CanvasItemMaterial::get_shader);
ObjectTypeDB::bind_method(_MD("set_shader_param","param","value"),&CanvasItemMaterial::set_shader_param);
ObjectTypeDB::bind_method(_MD("get_shader_param","param"),&CanvasItemMaterial::get_shader_param);
- ObjectTypeDB::bind_method(_MD("set_shading_mode","mode"),&CanvasItemMaterial::set_shading_mode);
- ObjectTypeDB::bind_method(_MD("get_shading_mode"),&CanvasItemMaterial::get_shading_mode);
- BIND_CONSTANT( SHADING_NORMAL );
- BIND_CONSTANT( SHADING_UNSHADED );
- BIND_CONSTANT( SHADING_ONLY_LIGHT );
}
@@ -189,13 +166,13 @@ void CanvasItemMaterial::get_argument_options(const StringName& p_function,int p
CanvasItemMaterial::CanvasItemMaterial() {
- material=VS::get_singleton()->canvas_item_material_create();
- shading_mode=SHADING_NORMAL;
+
+
}
CanvasItemMaterial::~CanvasItemMaterial(){
- VS::get_singleton()->free(material);
+
}
@@ -374,6 +351,8 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const {
return last_valid->canvas_layer->get_transform() * xform;
else if (is_inside_tree())
return get_viewport()->get_canvas_transform() * xform;
+
+ return xform;
}
Matrix32 CanvasItem::get_global_transform() const {
@@ -394,42 +373,17 @@ Matrix32 CanvasItem::get_global_transform() const {
}
-
-void CanvasItem::_queue_sort_children() {
-
- if (pending_children_sort)
- return;
-
- pending_children_sort=true;
- MessageQueue::get_singleton()->push_call(this,"_sort_children");
-}
-
-void CanvasItem::_sort_children() {
-
- pending_children_sort=false;
+void CanvasItem::_toplevel_raise_self() {
if (!is_inside_tree())
return;
- for(int i=0;i<get_child_count();i++) {
-
- Node *n = get_child(i);
- CanvasItem *ci=n->cast_to<CanvasItem>();
-
- if (ci) {
- if (ci->toplevel || ci->group!="")
- continue;
- VisualServer::get_singleton()->canvas_item_raise(n->cast_to<CanvasItem>()->canvas_item);
- }
- }
-}
-
-void CanvasItem::_raise_self() {
+ if (canvas_layer)
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,canvas_layer->get_sort_index());
+ else
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_viewport()->gui_get_canvas_sort_index());
- if (!is_inside_tree())
- return;
- VisualServer::get_singleton()->canvas_item_raise(canvas_item);
}
@@ -461,14 +415,19 @@ void CanvasItem::_enter_canvas() {
group = "root_canvas"+itos(canvas.get_id());
add_to_group(group);
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ if (canvas_layer)
+ canvas_layer->reset_sort_index();
+ else
+ get_viewport()->gui_reset_canvas_sort_index();
+
+ get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *parent = get_parent_item();
canvas_layer=parent->canvas_layer;
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
- parent->_queue_sort_children();
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index());
}
pending_update=false;
@@ -495,7 +454,6 @@ void CanvasItem::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
first_draw=true;
- pending_children_sort=false;
if (get_parent()) {
CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
if (ci)
@@ -508,13 +466,15 @@ void CanvasItem::_notification(int p_what) {
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
+ if (!is_inside_tree())
+ break;
if (group!="") {
- get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
+ get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_toplevel_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
- p->_queue_sort_children();
+ VisualServer::get_singleton()->canvas_item_set_draw_index(canvas_item,get_index());
}
@@ -569,15 +529,15 @@ void CanvasItem::update() {
MessageQueue::get_singleton()->push_call(this,"_update_callback");
}
-void CanvasItem::set_opacity(float p_opacity) {
+void CanvasItem::set_modulate(const Color& p_modulate) {
- opacity=p_opacity;
- VisualServer::get_singleton()->canvas_item_set_opacity(canvas_item,opacity);
+ modulate=p_modulate;
+ VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item,modulate);
}
-float CanvasItem::get_opacity() const {
+Color CanvasItem::get_modulate() const {
- return opacity;
+ return modulate;
}
@@ -614,29 +574,17 @@ CanvasItem *CanvasItem::get_parent_item() const {
}
-void CanvasItem::set_self_opacity(float p_self_opacity) {
+void CanvasItem::set_self_modulate(const Color& p_self_modulate) {
- self_opacity=p_self_opacity;
- VisualServer::get_singleton()->canvas_item_set_self_opacity(canvas_item,self_opacity);
-
-}
-float CanvasItem::get_self_opacity() const {
+ self_modulate=p_self_modulate;
+ VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item,self_modulate);
- return self_opacity;
}
+Color CanvasItem::get_self_modulate() const {
-void CanvasItem::set_blend_mode(BlendMode p_blend_mode) {
-
- ERR_FAIL_INDEX(p_blend_mode,5);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->canvas_item_set_blend_mode(canvas_item,VS::MaterialBlendMode(blend_mode));
-
+ return self_modulate;
}
-CanvasItem::BlendMode CanvasItem::get_blend_mode() const {
-
- return blend_mode;
-}
void CanvasItem::set_light_mask(int p_light_mask) {
@@ -913,7 +861,7 @@ void CanvasItem::set_draw_behind_parent(bool p_enable) {
if (behind==p_enable)
return;
behind=p_enable;
- VisualServer::get_singleton()->canvas_item_set_on_top(canvas_item,!behind);
+ VisualServer::get_singleton()->canvas_item_set_draw_behind_parent(canvas_item,behind);
}
@@ -983,8 +931,7 @@ Vector2 CanvasItem::get_local_mouse_pos() const{
void CanvasItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&CanvasItem::_sort_children);
- ObjectTypeDB::bind_method(_MD("_raise_self"),&CanvasItem::_raise_self);
+ ObjectTypeDB::bind_method(_MD("_toplevel_raise_self"),&CanvasItem::_toplevel_raise_self);
ObjectTypeDB::bind_method(_MD("_update_callback"),&CanvasItem::_update_callback);
ObjectTypeDB::bind_method(_MD("_set_visible_"),&CanvasItem::_set_visible_);
ObjectTypeDB::bind_method(_MD("_is_visible_"),&CanvasItem::_is_visible_);
@@ -1011,16 +958,13 @@ void CanvasItem::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_as_toplevel","enable"),&CanvasItem::set_as_toplevel);
ObjectTypeDB::bind_method(_MD("is_set_as_toplevel"),&CanvasItem::is_set_as_toplevel);
- ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&CanvasItem::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&CanvasItem::get_blend_mode);
-
ObjectTypeDB::bind_method(_MD("set_light_mask","light_mask"),&CanvasItem::set_light_mask);
ObjectTypeDB::bind_method(_MD("get_light_mask"),&CanvasItem::get_light_mask);
- ObjectTypeDB::bind_method(_MD("set_opacity","opacity"),&CanvasItem::set_opacity);
- ObjectTypeDB::bind_method(_MD("get_opacity"),&CanvasItem::get_opacity);
- ObjectTypeDB::bind_method(_MD("set_self_opacity","self_opacity"),&CanvasItem::set_self_opacity);
- ObjectTypeDB::bind_method(_MD("get_self_opacity"),&CanvasItem::get_self_opacity);
+ ObjectTypeDB::bind_method(_MD("set_modulate","modulate"),&CanvasItem::set_modulate);
+ ObjectTypeDB::bind_method(_MD("get_modulate"),&CanvasItem::get_modulate);
+ ObjectTypeDB::bind_method(_MD("set_self_modulate","self_modulate"),&CanvasItem::set_self_modulate);
+ ObjectTypeDB::bind_method(_MD("get_self_modulate"),&CanvasItem::get_self_modulate);
ObjectTypeDB::bind_method(_MD("set_draw_behind_parent","enable"),&CanvasItem::set_draw_behind_parent);
ObjectTypeDB::bind_method(_MD("is_draw_behind_parent_enabled"),&CanvasItem::is_draw_behind_parent_enabled);
@@ -1069,12 +1013,11 @@ void CanvasItem::_bind_methods() {
BIND_VMETHOD(MethodInfo("_draw"));
ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
- ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/modulate",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_modulate"),_SCS("get_modulate") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::REAL,"visibility/self_modulate",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_modulate"),_SCS("get_self_modulate") );
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
ADD_PROPERTYNO( PropertyInfo(Variant::INT,"visibility/light_mask",PROPERTY_HINT_ALL_FLAGS), _SCS("set_light_mask"),_SCS("get_light_mask") );
ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"material/material",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemMaterial"), _SCS("set_material"),_SCS("get_material") );
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"material/use_parent"), _SCS("set_use_parent_material"),_SCS("get_use_parent_material") );
@@ -1176,12 +1119,10 @@ CanvasItem::CanvasItem() : xform_change(this) {
canvas_item=VisualServer::get_singleton()->canvas_item_create();
hidden=false;
pending_update=false;
- opacity=1;
- self_opacity=1;
+ modulate=Color(1,1,1,1);
+ self_modulate=Color(1,1,1,1);
toplevel=false;
- pending_children_sort=false;
first_draw=false;
- blend_mode=BLEND_MODE_MIX;
drawing=false;
behind=false;
block_transform_notify=false;
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 7849a66185..b65c1a60b4 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -33,6 +33,7 @@
#include "scene/resources/texture.h"
#include "scene/main/scene_main_loop.h"
#include "scene/resources/shader.h"
+#include "scene/resources/material.h"
class CanvasLayer;
class Viewport;
@@ -40,22 +41,19 @@ class Font;
class StyleBox;
-class CanvasItemMaterial : public Resource{
+class CanvasItemMaterial : public Material{
- OBJ_TYPE(CanvasItemMaterial,Resource);
+ OBJ_TYPE(CanvasItemMaterial,Material);
RID material;
Ref<Shader> shader;
public:
- enum ShadingMode {
+ /*enum ShadingMode {
SHADING_NORMAL,
SHADING_UNSHADED,
SHADING_ONLY_LIGHT,
- };
+ };*/
protected:
-
- ShadingMode shading_mode;
-
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
void _get_property_list( List<PropertyInfo> *p_list) const;
@@ -72,15 +70,12 @@ public:
void set_shader_param(const StringName& p_param,const Variant& p_value);
Variant get_shader_param(const StringName& p_param) const;
- void set_shading_mode(ShadingMode p_mode);
- ShadingMode get_shading_mode() const;
-
virtual RID get_rid() const;
CanvasItemMaterial();
~CanvasItemMaterial();
};
-VARIANT_ENUM_CAST( CanvasItemMaterial::ShadingMode );
+
class CanvasItem : public Node {
@@ -107,8 +102,8 @@ private:
CanvasLayer *canvas_layer;
- float opacity;
- float self_opacity;
+ Color modulate;
+ Color self_modulate;
List<CanvasItem*> children_items;
List<CanvasItem*>::Element *C;
@@ -120,7 +115,6 @@ private:
bool hidden;
bool pending_update;
bool toplevel;
- bool pending_children_sort;
bool drawing;
bool block_transform_notify;
bool behind;
@@ -133,7 +127,7 @@ private:
mutable bool global_invalid;
- void _raise_self();
+ void _toplevel_raise_self();
void _propagate_visibility_changed(bool p_visible);
@@ -145,9 +139,6 @@ private:
void _enter_canvas();
void _exit_canvas();
- void _queue_sort_children();
- void _sort_children();
-
void _notify_transform(CanvasItem *p_node);
void _set_on_top(bool p_on_top) { set_draw_behind_parent(!p_on_top); }
@@ -193,17 +184,14 @@ public:
void update();
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
-
virtual void set_light_mask(int p_light_mask);
int get_light_mask() const;
- void set_opacity(float p_opacity);
- float get_opacity() const;
+ void set_modulate(const Color& p_modulate);
+ Color get_modulate() const;
- void set_self_opacity(float p_self_opacity);
- float get_self_opacity() const;
+ void set_self_modulate(const Color& p_self_modulate);
+ Color get_self_modulate() const;
/* DRAWING API */
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index f37cef673d..8e5b8ba0a4 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -208,26 +208,26 @@ int Light2D::get_layer_range_max() const {
return layer_max;
}
-void Light2D::set_item_mask( int p_mask) {
+void Light2D::set_item_cull_mask( int p_mask) {
item_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_mask(canvas_light,item_mask);
+ VS::get_singleton()->canvas_light_set_item_cull_mask(canvas_light,item_mask);
}
-int Light2D::get_item_mask() const {
+int Light2D::get_item_cull_mask() const {
return item_mask;
}
-void Light2D::set_item_shadow_mask( int p_mask) {
+void Light2D::set_item_shadow_cull_mask( int p_mask) {
item_shadow_mask=p_mask;
- VS::get_singleton()->canvas_light_set_item_shadow_mask(canvas_light,item_shadow_mask);
+ VS::get_singleton()->canvas_light_set_item_shadow_cull_mask(canvas_light,item_shadow_mask);
}
-int Light2D::get_item_shadow_mask() const {
+int Light2D::get_item_shadow_cull_mask() const {
return item_shadow_mask;
}
@@ -265,17 +265,30 @@ int Light2D::get_shadow_buffer_size() const {
return shadow_buffer_size;
}
-void Light2D::set_shadow_esm_multiplier( float p_multiplier) {
+void Light2D::set_shadow_gradient_length( float p_multiplier) {
- shadow_esm_multiplier=p_multiplier;
- VS::get_singleton()->canvas_light_set_shadow_esm_multiplier(canvas_light,p_multiplier);
+ shadow_gradient_length=p_multiplier;
+ VS::get_singleton()->canvas_light_set_shadow_gradient_length(canvas_light,p_multiplier);
}
-float Light2D::get_shadow_esm_multiplier() const{
+float Light2D::get_shadow_gradient_length() const{
- return shadow_esm_multiplier;
+ return shadow_gradient_length;
}
+
+void Light2D::set_shadow_filter( ShadowFilter p_filter) {
+ shadow_filter=p_filter;
+ VS::get_singleton()->canvas_light_set_shadow_filter(canvas_light,VS::CanvasLightShadowFilter(p_filter ));
+}
+
+Light2D::ShadowFilter Light2D::get_shadow_filter() const {
+
+ return shadow_filter;
+}
+
+
+
void Light2D::set_shadow_color( const Color& p_shadow_color) {
shadow_color=p_shadow_color;
VS::get_singleton()->canvas_light_set_shadow_color(canvas_light,shadow_color);
@@ -360,11 +373,11 @@ void Light2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_layer_range_max"),&Light2D::get_layer_range_max);
- ObjectTypeDB::bind_method(_MD("set_item_mask","item_mask"),&Light2D::set_item_mask);
- ObjectTypeDB::bind_method(_MD("get_item_mask"),&Light2D::get_item_mask);
+ ObjectTypeDB::bind_method(_MD("set_item_cull_mask","item_cull_mask"),&Light2D::set_item_cull_mask);
+ ObjectTypeDB::bind_method(_MD("get_item_cull_mask"),&Light2D::get_item_cull_mask);
- ObjectTypeDB::bind_method(_MD("set_item_shadow_mask","item_shadow_mask"),&Light2D::set_item_shadow_mask);
- ObjectTypeDB::bind_method(_MD("get_item_shadow_mask"),&Light2D::get_item_shadow_mask);
+ ObjectTypeDB::bind_method(_MD("set_item_shadow_cull_mask","item_shadow_cull_mask"),&Light2D::set_item_shadow_cull_mask);
+ ObjectTypeDB::bind_method(_MD("get_item_shadow_cull_mask"),&Light2D::get_item_shadow_cull_mask);
ObjectTypeDB::bind_method(_MD("set_mode","mode"),&Light2D::set_mode);
ObjectTypeDB::bind_method(_MD("get_mode"),&Light2D::get_mode);
@@ -375,8 +388,11 @@ void Light2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_shadow_buffer_size","size"),&Light2D::set_shadow_buffer_size);
ObjectTypeDB::bind_method(_MD("get_shadow_buffer_size"),&Light2D::get_shadow_buffer_size);
- ObjectTypeDB::bind_method(_MD("set_shadow_esm_multiplier","multiplier"),&Light2D::set_shadow_esm_multiplier);
- ObjectTypeDB::bind_method(_MD("get_shadow_esm_multiplier"),&Light2D::get_shadow_esm_multiplier);
+ ObjectTypeDB::bind_method(_MD("set_shadow_gradient_length","multiplier"),&Light2D::set_shadow_gradient_length);
+ ObjectTypeDB::bind_method(_MD("get_shadow_gradient_length"),&Light2D::get_shadow_gradient_length);
+
+ ObjectTypeDB::bind_method(_MD("set_shadow_filter","filter"),&Light2D::set_shadow_filter);
+ ObjectTypeDB::bind_method(_MD("get_shadow_filter"),&Light2D::get_shadow_filter);
ObjectTypeDB::bind_method(_MD("set_shadow_color","shadow_color"),&Light2D::set_shadow_color);
ObjectTypeDB::bind_method(_MD("get_shadow_color"),&Light2D::get_shadow_color);
@@ -394,12 +410,13 @@ void Light2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/z_max",PROPERTY_HINT_RANGE,itos(VS::CANVAS_ITEM_Z_MIN)+","+itos(VS::CANVAS_ITEM_Z_MAX)+",1"),_SCS("set_z_range_max"),_SCS("get_z_range_max"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_min",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_min"),_SCS("get_layer_range_min"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"range/layer_max",PROPERTY_HINT_RANGE,"-512,512,1"),_SCS("set_layer_range_max"),_SCS("get_layer_range_max"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"range/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_mask"),_SCS("get_item_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"range/item_cull_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_cull_mask"),_SCS("get_item_cull_mask"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"shadow/enabled"),_SCS("set_shadow_enabled"),_SCS("is_shadow_enabled"));
ADD_PROPERTY( PropertyInfo(Variant::COLOR,"shadow/color"),_SCS("set_shadow_color"),_SCS("get_shadow_color"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/buffer_size",PROPERTY_HINT_RANGE,"32,16384,1"),_SCS("set_shadow_buffer_size"),_SCS("get_shadow_buffer_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/esm_multiplier",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_esm_multiplier"),_SCS("get_shadow_esm_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_mask"),_SCS("get_item_shadow_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/gradient_length",PROPERTY_HINT_RANGE,"1,4096,0.1"),_SCS("set_shadow_gradient_length"),_SCS("get_shadow_gradient_length"));
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"shadow/filter",PROPERTY_HINT_ENUM,"None,PCF3,PCF5,PCF9,PCF13"),_SCS("set_shadow_filter"),_SCS("get_shadow_filter"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/item_cull_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_item_shadow_cull_mask"),_SCS("get_item_shadow_cull_mask"));
BIND_CONSTANT( MODE_ADD );
BIND_CONSTANT( MODE_SUB );
@@ -425,9 +442,10 @@ Light2D::Light2D() {
item_shadow_mask=1;
mode=MODE_ADD;
shadow_buffer_size=2048;
- shadow_esm_multiplier=80;
+ shadow_gradient_length=0;
energy=1.0;
shadow_color=Color(0,0,0,0);
+ shadow_filter=SHADOW_FILTER_NONE;
}
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index c03ef96eff..75dcf67936 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -42,6 +42,14 @@ public:
MODE_MASK,
};
+ enum ShadowFilter {
+ SHADOW_FILTER_NONE,
+ SHADOW_FILTER_PCF3,
+ SHADOW_FILTER_PCF5,
+ SHADOW_FILTER_PCF9,
+ SHADOW_FILTER_PCF13,
+ };
+
private:
RID canvas_light;
bool enabled;
@@ -58,10 +66,12 @@ private:
int item_mask;
int item_shadow_mask;
int shadow_buffer_size;
- float shadow_esm_multiplier;
+ float shadow_gradient_length;
Mode mode;
Ref<Texture> texture;
Vector2 texture_offset;
+ ShadowFilter shadow_filter;
+
void _update_light_visibility();
protected:
@@ -108,11 +118,11 @@ public:
void set_layer_range_max( int p_max_layer);
int get_layer_range_max() const;
- void set_item_mask( int p_mask);
- int get_item_mask() const;
+ void set_item_cull_mask( int p_mask);
+ int get_item_cull_mask() const;
- void set_item_shadow_mask( int p_mask);
- int get_item_shadow_mask() const;
+ void set_item_shadow_cull_mask( int p_mask);
+ int get_item_shadow_cull_mask() const;
void set_mode( Mode p_mode );
Mode get_mode() const;
@@ -123,8 +133,11 @@ public:
void set_shadow_buffer_size( int p_size );
int get_shadow_buffer_size() const;
- void set_shadow_esm_multiplier( float p_multiplier);
- float get_shadow_esm_multiplier() const;
+ void set_shadow_gradient_length( float p_multiplier);
+ float get_shadow_gradient_length() const;
+
+ void set_shadow_filter( ShadowFilter p_filter);
+ ShadowFilter get_shadow_filter() const;
void set_shadow_color( const Color& p_shadow_color);
Color get_shadow_color() const;
@@ -139,5 +152,7 @@ public:
};
VARIANT_ENUM_CAST(Light2D::Mode);
+VARIANT_ENUM_CAST(Light2D::ShadowFilter);
+
#endif // LIGHT_2D_H
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index c5b338bf59..00ce59a6f6 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -376,7 +376,7 @@ Sprite::Sprite() {
///
///
-
+#if 0
void ViewportSprite::edit_set_pivot(const Point2& p_pivot) {
set_offset(p_pivot);
@@ -588,3 +588,4 @@ ViewportSprite::ViewportSprite() {
centered=true;
modulate=Color(1,1,1,1);
}
+#endif
diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h
index 32d3f476d1..2e7b753a04 100644
--- a/scene/2d/sprite.h
+++ b/scene/2d/sprite.h
@@ -107,6 +107,7 @@ public:
Sprite();
};
+#if 0
class ViewportSprite : public Node2D {
OBJ_TYPE( ViewportSprite, Node2D );
@@ -149,4 +150,5 @@ public:
ViewportSprite();
};
+#endif
#endif // SPRITE_H
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 1a4f88c30e..972ce8378a 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -477,7 +477,7 @@ void TileMap::_update_dirty_quadrants() {
_fix_cell_transform(xform,c,shape_ofs+center_ofs,s);
- if (debug_canvas_item) {
+ if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item,xform);
shape->draw(debug_canvas_item,debug_collision_color);
@@ -488,7 +488,7 @@ void TileMap::_update_dirty_quadrants() {
}
}
- if (debug_canvas_item) {
+ if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item,Matrix32());
}
@@ -541,26 +541,19 @@ void TileMap::_update_dirty_quadrants() {
if (quadrant_order_dirty) {
+ int index=-0x80000000; //always must be drawn below children
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
Quadrant &q=E->get();
for (List<RID>::Element *E=q.canvas_items.front();E;E=E->next()) {
- VS::get_singleton()->canvas_item_raise(E->get());
+ VS::get_singleton()->canvas_item_set_draw_index(E->get(),index++);
}
}
quadrant_order_dirty=false;
}
- for(int i=0;i<get_child_count();i++) {
-
- CanvasItem *c=get_child(i)->cast_to<CanvasItem>();
-
- if (c)
- VS::get_singleton()->canvas_item_raise(c->get_canvas_item());
- }
-
_recompute_rect_cache();
}
diff --git a/scene/3d/baked_light_instance.cpp b/scene/3d/baked_light_instance.cpp
index ca3a309568..07f0e4ee57 100644
--- a/scene/3d/baked_light_instance.cpp
+++ b/scene/3d/baked_light_instance.cpp
@@ -29,6 +29,7 @@
#include "baked_light_instance.h"
#include "scene/scene_string_names.h"
+#if 0
RID BakedLightInstance::get_baked_light_instance() const {
@@ -179,3 +180,4 @@ BakedLightSampler::~BakedLightSampler(){
VS::get_singleton()->free(base);
}
+#endif
diff --git a/scene/3d/baked_light_instance.h b/scene/3d/baked_light_instance.h
index 002e55df1d..15f04fea31 100644
--- a/scene/3d/baked_light_instance.h
+++ b/scene/3d/baked_light_instance.h
@@ -32,6 +32,7 @@
#include "scene/3d/visual_instance.h"
#include "scene/resources/baked_light.h"
+#if 0
class BakedLightBaker;
@@ -101,5 +102,5 @@ public:
VARIANT_ENUM_CAST( BakedLightSampler::Param );
-
+#endif
#endif // BAKED_LIGHT_H
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index e76c0938fb..1ce07b0264 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -96,8 +96,8 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
} else {
clear_current();
}
- } else if (p_name=="visible_layers") {
- set_visible_layers(p_value);
+ } else if (p_name=="cull_mask") {
+ set_cull_mask(p_value);
} else if (p_name=="environment") {
set_environment(p_value);
} else
@@ -130,8 +130,8 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
} else {
r_ret=is_current();
}
- } else if (p_name=="visible_layers") {
- r_ret=get_visible_layers();
+ } else if (p_name=="cull_mask") {
+ r_ret=get_cull_mask();
} else if (p_name=="h_offset") {
r_ret=get_h_offset();
} else if (p_name=="v_offset") {
@@ -176,7 +176,7 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::REAL, "far" , PROPERTY_HINT_EXP_RANGE, "0.01,4096.0,0.01") );
p_list->push_back( PropertyInfo( Variant::INT, "keep_aspect",PROPERTY_HINT_ENUM,"Keep Width,Keep Height") );
p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
- p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
+ p_list->push_back( PropertyInfo( Variant::INT, "cull_mask",PROPERTY_HINT_ALL_FLAGS ) );
p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
@@ -342,91 +342,6 @@ bool Camera::_can_gizmo_scale() const {
}
-RES Camera::_get_gizmo_geometry() const {
-
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.5,1.0,0.5) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
- //mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- switch(mode) {
-
- case PROJECTION_PERSPECTIVE: {
-
-
-
- Vector3 side=Vector3( Math::sin(Math::deg2rad(fov)), 0, -Math::cos(Math::deg2rad(fov)) );
- Vector3 nside=side;
- nside.x=-nside.x;
- Vector3 up=Vector3(0,side.x,0);
-
-
-#define ADD_TRIANGLE( m_a, m_b, m_c)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_a);\
-}
-
- ADD_TRIANGLE( Vector3(), side+up, side-up );
- ADD_TRIANGLE( Vector3(), nside+up, nside-up );
- ADD_TRIANGLE( Vector3(), side+up, nside+up );
- ADD_TRIANGLE( Vector3(), side-up, nside-up );
-
- side.x*=0.25;
- nside.x*=0.25;
- Vector3 tup( 0, up.y*3/2,side.z);
- ADD_TRIANGLE( tup, side+up, nside+up );
-
- } break;
- case PROJECTION_ORTHOGONAL: {
-
-#define ADD_QUAD( m_a, m_b, m_c, m_d)\
-{\
- surface_tool->add_vertex(m_a);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_b);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_c);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_d);\
- surface_tool->add_vertex(m_a);\
-}
-
- float hsize=size*0.5;
- Vector3 right(hsize,0,0);
- Vector3 up(0,hsize,0);
- Vector3 back(0,0,-1.0);
- Vector3 front(0,0,0);
-
- ADD_QUAD( -up-right,-up+right,up+right,up-right);
- ADD_QUAD( -up-right+back,-up+right+back,up+right+back,up-right+back);
- ADD_QUAD( up+right,up+right+back,up-right+back,up-right);
- ADD_QUAD( -up+right,-up+right+back,-up-right+back,-up-right);
-
- right.x*=0.25;
- Vector3 tup( 0, up.y*3/2,back.z );
- ADD_TRIANGLE( tup, right+up+back, -right+up+back );
-
- } break;
-
- }
-
- return surface_tool->commit();
-
-}
Vector3 Camera::project_ray_normal(const Point2& p_pos) const {
@@ -648,8 +563,8 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
ObjectTypeDB::bind_method( _MD("get_znear"),&Camera::get_znear );
ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
- ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
- ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
+ ObjectTypeDB::bind_method( _MD("set_cull_mask","mask"),&Camera::set_cull_mask );
+ ObjectTypeDB::bind_method( _MD("get_cull_mask"),&Camera::get_cull_mask );
ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment);
ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment);
ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode);
@@ -690,13 +605,13 @@ Camera::Projection Camera::get_projection() const {
return mode;
}
-void Camera::set_visible_layers(uint32_t p_layers) {
+void Camera::set_cull_mask(uint32_t p_layers) {
layers=p_layers;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
}
-uint32_t Camera::get_visible_layers() const{
+uint32_t Camera::get_cull_mask() const{
return layers;
}
@@ -757,7 +672,7 @@ Camera::Camera() {
layers=0xfffff;
v_offset=0;
h_offset=0;
- VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
+ VisualServer::get_singleton()->camera_set_cull_mask(camera,layers);
//active=false;
}
diff --git a/scene/3d/camera.h b/scene/3d/camera.h
index 30c6928245..3ea0bd711c 100644
--- a/scene/3d/camera.h
+++ b/scene/3d/camera.h
@@ -75,7 +75,7 @@ private:
Ref<Environment> environment;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
+
//void _camera_make_current(Node *p_camera);
@@ -126,8 +126,8 @@ public:
bool is_position_behind(const Vector3& p_pos) const;
Vector3 project_position(const Point2& p_point) const;
- void set_visible_layers(uint32_t p_layers);
- uint32_t get_visible_layers() const;
+ void set_cull_mask(uint32_t p_layers);
+ uint32_t get_cull_mask() const;
Vector<Plane> get_frustum() const;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 227bb3a59d..d98f100020 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -32,75 +32,6 @@
#include "scene/resources/surface_tool.h"
-static const char* _light_param_names[VS::LIGHT_PARAM_MAX]={
- "params/spot_attenuation",
- "params/spot_angle",
- "params/radius",
- "params/energy",
- "params/attenuation",
- "shadow/darkening",
- "shadow/z_offset",
- "shadow/z_slope_scale",
- "shadow/esm_multiplier",
- "shadow/blur_passes"
-};
-
-void Light::set_parameter(Parameter p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param, PARAM_MAX);
- vars[p_param]=p_value;
- VisualServer::get_singleton()->light_set_param(light,(VisualServer::LightParam)p_param,p_value);
- if (p_param==PARAM_RADIUS || p_param==PARAM_SPOT_ANGLE)
- update_gizmo();
- _change_notify(_light_param_names[p_param]);
-// _change_notify(_param_names[p_param]);
-}
-
-float Light::get_parameter(Parameter p_param) const {
-
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0);
- return vars[p_param];
-
-}
-
-void Light::set_color(LightColor p_color, const Color& p_value) {
-
- ERR_FAIL_INDEX(p_color, 3);
- colors[p_color]=p_value;
- VisualServer::get_singleton()->light_set_color(light,(VisualServer::LightColor)p_color,p_value);
- //_change_notify(_color_names[p_color]);
-
-}
-Color Light::get_color(LightColor p_color) const {
-
- ERR_FAIL_INDEX_V(p_color, 3, Color());
- return colors[p_color];
-
-}
-
-
-void Light::set_project_shadows(bool p_enabled) {
-
- shadows=p_enabled;
- VisualServer::get_singleton()->light_set_shadow(light, p_enabled);
- _change_notify("shadow");
-}
-bool Light::has_project_shadows() const {
-
- return shadows;
-}
-
-void Light::set_projector(const Ref<Texture>& p_projector) {
-
- projector=p_projector;
- VisualServer::get_singleton()->light_set_projector(light, projector.is_null()?RID():projector->get_rid());
-}
-
-Ref<Texture> Light::get_projector() const {
-
- return projector;
-}
-
bool Light::_can_gizmo_scale() const {
@@ -108,220 +39,9 @@ bool Light::_can_gizmo_scale() const {
}
-static void _make_sphere(int p_lats, int p_lons, float p_radius, Ref<SurfaceTool> p_tool) {
-
-
- p_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- for(int i = 1; i <= p_lats; i++) {
- double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats);
- double z0 = Math::sin(lat0);
- double zr0 = Math::cos(lat0);
-
- double lat1 = Math_PI * (-0.5 + (double) i / p_lats);
- double z1 = Math::sin(lat1);
- double zr1 = Math::cos(lat1);
-
- for(int j = p_lons; j >= 1; j--) {
-
- double lng0 = 2 * Math_PI * (double) (j - 1) / p_lons;
- double x0 = Math::cos(lng0);
- double y0 = Math::sin(lng0);
-
- double lng1 = 2 * Math_PI * (double) (j) / p_lons;
- double x1 = Math::cos(lng1);
- double y1 = Math::sin(lng1);
-
-
- Vector3 v[4]={
- Vector3(x1 * zr0, z0, y1 *zr0),
- Vector3(x1 * zr1, z1, y1 *zr1),
- Vector3(x0 * zr1, z1, y0 *zr1),
- Vector3(x0 * zr0, z0, y0 *zr0)
- };
-
-#define ADD_POINT(m_idx) \
- p_tool->add_normal(v[m_idx]);\
- p_tool->add_vertex(v[m_idx]*p_radius);
-
- ADD_POINT(0);
- ADD_POINT(1);
- ADD_POINT(2);
-
- ADD_POINT(2);
- ADD_POINT(3);
- ADD_POINT(0);
- }
- }
-
-}
-
-RES Light::_get_gizmo_geometry() const {
-
-
- Ref<FixedMaterial> mat_area( memnew( FixedMaterial ));
-
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.7,0.6,0.0,0.05) );
- mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
- mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));
-
- mat_light->set_parameter( FixedMaterial::PARAM_DIFFUSE, Color(1.0,1.0,0.8,0.9) );
- mat_light->set_flag(Material::FLAG_UNSHADED,true);
-
- Ref< Mesh > mesh;
-
- Ref<SurfaceTool> surftool( memnew( SurfaceTool ));
-
- switch(type) {
-
- case VisualServer::LIGHT_DIRECTIONAL: {
-
-
- mat_area->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.9,0.8,0.1,0.8) );
- mat_area->set_blend_mode( Material::BLEND_MODE_MIX);
- mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,false);
- mat_area->set_flag(Material::FLAG_UNSHADED,true);
-
- _make_sphere( 5,5,0.6, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
-
- // float radius=1;
-
- surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- const int arrow_points=5;
- Vector3 arrow[arrow_points]={
- Vector3(0,0,2),
- Vector3(1,1,2),
- Vector3(1,1,-1),
- Vector3(2,2,-1),
- Vector3(0,0,-3)
- };
-
- int arrow_sides=4;
-
-
- for(int i = 0; i < arrow_sides ; i++) {
-
-
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/arrow_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/arrow_sides);
-
-
- for(int j=0;j<arrow_points-1;j++) {
-
- Vector3 points[4]={
- ma.xform(arrow[j]),
- mb.xform(arrow[j]),
- mb.xform(arrow[j+1]),
- ma.xform(arrow[j+1]),
- };
-
- Vector3 n = Plane(points[0],points[1],points[2]).normal;
-
- surftool->add_normal(n);
- surftool->add_vertex(points[0]);
- surftool->add_normal(n);
- surftool->add_vertex(points[1]);
- surftool->add_normal(n);
- surftool->add_vertex(points[2]);
-
- surftool->add_normal(n);
- surftool->add_vertex(points[0]);
- surftool->add_normal(n);
- surftool->add_vertex(points[2]);
- surftool->add_normal(n);
- surftool->add_vertex(points[3]);
-
-
- }
-
-
- }
-
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
-
-
- } break;
- case VisualServer::LIGHT_OMNI: {
-
-
- _make_sphere( 20,20,vars[PARAM_RADIUS], surftool );
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
- _make_sphere(5,5, 0.1, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
- } break;
-
- case VisualServer::LIGHT_SPOT: {
-
- _make_sphere( 5,5,0.1, surftool );
- surftool->set_material(mat_light);
- mesh=surftool->commit(mesh);
-
- // make cone
- int points=24;
- float len=vars[PARAM_RADIUS];
- float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
-
- surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
-
- for(int i = 0; i < points; i++) {
-
- float x0=Math::sin(i * Math_PI * 2 / points);
- float y0=Math::cos(i * Math_PI * 2 / points);
- float x1=Math::sin((i+1) * Math_PI * 2 / points);
- float y1=Math::cos((i+1) * Math_PI * 2 / points);
-
- Vector3 v1=Vector3(x0*size,y0*size,-len).normalized()*len;
- Vector3 v2=Vector3(x1*size,y1*size,-len).normalized()*len;
-
- Vector3 v3=Vector3(0,0,0);
- Vector3 v4=Vector3(0,0,v1.z);
-
- Vector3 n = Plane(v1,v2,v3).normal;
-
-
- surftool->add_normal(n);
- surftool->add_vertex(v1);
- surftool->add_normal(n);
- surftool->add_vertex(v2);
- surftool->add_normal(n);
- surftool->add_vertex(v3);
-
- n=Vector3(0,0,-1);
-
- surftool->add_normal(n);
- surftool->add_vertex(v1);
- surftool->add_normal(n);
- surftool->add_vertex(v2);
- surftool->add_normal(n);
- surftool->add_vertex(v4);
-
-
- }
-
- surftool->set_material(mat_area);
- mesh=surftool->commit(mesh);
-
-
- } break;
- }
-
- return mesh;
-}
-
-
AABB Light::get_aabb() const {
+#if 0
if (type==VisualServer::LIGHT_DIRECTIONAL) {
return AABB( Vector3(-1,-1,-1), Vector3(2, 2, 2 ) );
@@ -336,7 +56,7 @@ AABB Light::get_aabb() const {
float size=Math::tan(Math::deg2rad(vars[PARAM_SPOT_ANGLE]))*len;
return AABB( Vector3( -size,-size,-len ), Vector3( size*2, size*2, len ) );
}
-
+#endif
return AABB();
}
@@ -346,89 +66,6 @@ DVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
}
-void Light::set_operator(Operator p_op) {
- ERR_FAIL_INDEX(p_op,2);
- op=p_op;
- VisualServer::get_singleton()->light_set_operator(light,VS::LightOp(op));
-
-}
-
-void Light::set_bake_mode(BakeMode p_bake_mode) {
-
- bake_mode=p_bake_mode;
-}
-
-Light::BakeMode Light::get_bake_mode() const {
-
- return bake_mode;
-}
-
-
-Light::Operator Light::get_operator() const {
-
- return op;
-}
-
-void Light::approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic,float p_radius_treshold) {
-
- //this is horrible and must never be used
-
- float a = p_quadratic * p_radius_treshold;
- float b = p_linear * p_radius_treshold;
- float c = p_constant * p_radius_treshold -1;
-
- float radius=10000;
-
- if(a == 0) { // solve linear
- float d = Math::abs(-c/b);
- if(d<radius)
- radius=d;
-
-
- } else { // solve quadratic
- // now ad^2 + bd + c = 0, solve quadratic equation:
-
- float denominator = 2*a;
-
- if(denominator != 0) {
-
-
- float root = b*b - 4*a*c;
-
- if(root >=0) {
-
- root = sqrt(root);
-
- float solution1 = fabs( (-b + root) / denominator);
- float solution2 = fabs( (-b - root) / denominator);
-
- if(solution1 > radius)
- solution1 = radius;
-
- if(solution2 > radius)
- solution2 = radius;
-
- radius = (solution1 > solution2 ? solution1 : solution2);
- }
- }
- }
-
- float energy=1.0;
-
- /*if (p_constant>0)
- energy=1.0/p_constant; //energy is this
- else
- energy=8.0; // some high number..
-*/
-
- if (radius==10000)
- radius=100; //bug?
-
- set_parameter(PARAM_RADIUS,radius);
- set_parameter(PARAM_ENERGY,energy);
-
-}
-
void Light::_update_visibility() {
@@ -436,7 +73,7 @@ void Light::_update_visibility() {
return;
-bool editor_ok=true;
+ bool editor_ok=true;
#ifdef TOOLS_ENABLED
if (editor_only) {
@@ -448,7 +85,7 @@ bool editor_ok=true;
}
#endif
- VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
+ //VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && editor_ok);
_change_notify("geometry/visible");
}
@@ -461,16 +98,6 @@ void Light::_notification(int p_what) {
}
}
-void Light::set_enabled(bool p_enabled) {
-
- enabled=p_enabled;
- _update_visibility();
-}
-
-bool Light::is_enabled() const{
-
- return enabled;
-}
void Light::set_editor_only(bool p_editor_only) {
@@ -486,68 +113,15 @@ bool Light::is_editor_only() const{
void Light::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_parameter","variable","value"), &Light::set_parameter );
- ObjectTypeDB::bind_method(_MD("get_parameter","variable"), &Light::get_parameter );
- ObjectTypeDB::bind_method(_MD("set_color","color","value"), &Light::set_color );
- ObjectTypeDB::bind_method(_MD("get_color","color"), &Light::get_color );
- ObjectTypeDB::bind_method(_MD("set_project_shadows","enable"), &Light::set_project_shadows );
- ObjectTypeDB::bind_method(_MD("has_project_shadows"), &Light::has_project_shadows );
- ObjectTypeDB::bind_method(_MD("set_projector","projector:Texture"), &Light::set_projector );
- ObjectTypeDB::bind_method(_MD("get_projector:Texture"), &Light::get_projector );
- ObjectTypeDB::bind_method(_MD("set_operator","operator"), &Light::set_operator );
- ObjectTypeDB::bind_method(_MD("get_operator"), &Light::get_operator );
- ObjectTypeDB::bind_method(_MD("set_bake_mode","bake_mode"), &Light::set_bake_mode );
- ObjectTypeDB::bind_method(_MD("get_bake_mode"), &Light::get_bake_mode );
- ObjectTypeDB::bind_method(_MD("set_enabled","enabled"), &Light::set_enabled );
- ObjectTypeDB::bind_method(_MD("is_enabled"), &Light::is_enabled );
+
ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light::set_editor_only );
ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light::is_editor_only );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/enabled"), _SCS("set_enabled"), _SCS("is_enabled"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "params/editor_only"), _SCS("set_editor_only"), _SCS("is_editor_only"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/bake_mode",PROPERTY_HINT_ENUM,"Disabled,Indirect,Indirect+Shadows,Full"), _SCS("set_bake_mode"), _SCS("get_bake_mode"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/energy", PROPERTY_HINT_EXP_RANGE, "0,64,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ENERGY );
- /*
- if (type == VisualServer::LIGHT_OMNI || type == VisualServer::LIGHT_SPOT) {
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_RANGE, "0.01,4096,0.01"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_RANGE, "0,8,0.01"));
- }
- if (type == VisualServer::LIGHT_SPOT) {
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,90.0,0.01"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_RANGE, "0,8,0.01"));
- }*/
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/diffuse"), _SCS("set_color"), _SCS("get_color"),COLOR_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/specular"), _SCS("set_color"), _SCS("get_color"),COLOR_SPECULAR);
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow/shadow"), _SCS("set_project_shadows"), _SCS("has_project_shadows"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/darkening", PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_DARKENING );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_offset", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_OFFSET);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/z_slope_scale", PROPERTY_HINT_RANGE, "0,128,0.001"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_Z_SLOPE_SCALE);
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "shadow/esm_multiplier", PROPERTY_HINT_RANGE, "1.0,512.0,0.1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_ESM_MULTIPLIER);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, "shadow/blur_passes", PROPERTY_HINT_RANGE, "0,4,1"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADOW_BLUR_PASSES);
- ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "projector",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_projector"), _SCS("get_projector"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "operator",PROPERTY_HINT_ENUM,"Add,Sub"), _SCS("set_operator"), _SCS("get_operator"));
-
-
- BIND_CONSTANT( PARAM_RADIUS );
- BIND_CONSTANT( PARAM_ENERGY );
- BIND_CONSTANT( PARAM_ATTENUATION );
- BIND_CONSTANT( PARAM_SPOT_ANGLE );
- BIND_CONSTANT( PARAM_SPOT_ATTENUATION );
- BIND_CONSTANT( PARAM_SHADOW_DARKENING );
- BIND_CONSTANT( PARAM_SHADOW_Z_OFFSET );
-
-
- BIND_CONSTANT( COLOR_DIFFUSE );
- BIND_CONSTANT( COLOR_SPECULAR );
-
- BIND_CONSTANT( BAKE_MODE_DISABLED );
- BIND_CONSTANT( BAKE_MODE_INDIRECT );
- BIND_CONSTANT( BAKE_MODE_INDIRECT_AND_SHADOWS );
- BIND_CONSTANT( BAKE_MODE_FULL );
}
@@ -558,27 +132,8 @@ Light::Light(VisualServer::LightType p_type) {
type=p_type;
light=VisualServer::get_singleton()->light_create(p_type);
- set_parameter(PARAM_SPOT_ATTENUATION,1.0);
- set_parameter(PARAM_SPOT_ANGLE,30.0);
- set_parameter(PARAM_RADIUS,2.0);
- set_parameter(PARAM_ENERGY,1.0);
- set_parameter(PARAM_ATTENUATION,1.0);
- set_parameter(PARAM_SHADOW_DARKENING,0.0);
- set_parameter(PARAM_SHADOW_Z_OFFSET,0.05);
- set_parameter(PARAM_SHADOW_Z_SLOPE_SCALE,0);
- set_parameter(PARAM_SHADOW_ESM_MULTIPLIER,60);
- set_parameter(PARAM_SHADOW_BLUR_PASSES,1);
-
-
- set_color( COLOR_DIFFUSE, Color(1,1,1));
- set_color( COLOR_SPECULAR, Color(1,1,1));
-
- op=OPERATOR_ADD;
- set_project_shadows( false );
- set_base(light);
- enabled=true;
+
editor_only=false;
- bake_mode=BAKE_MODE_DISABLED;
}
@@ -598,59 +153,15 @@ Light::~Light() {
/////////////////////////////////////////
-void DirectionalLight::set_shadow_mode(ShadowMode p_mode) {
-
- shadow_mode=p_mode;
- VS::get_singleton()->light_directional_set_shadow_mode(light,(VS::LightDirectionalShadowMode)p_mode);
-
-}
-
-DirectionalLight::ShadowMode DirectionalLight::get_shadow_mode() const{
-
- return shadow_mode;
-}
-
-void DirectionalLight::set_shadow_param(ShadowParam p_param, float p_value) {
-
- ERR_FAIL_INDEX(p_param,3);
- shadow_param[p_param]=p_value;
- VS::get_singleton()->light_directional_set_shadow_param(light,VS::LightDirectionalShadowParam(p_param),p_value);
-}
-
-float DirectionalLight::get_shadow_param(ShadowParam p_param) const {
- ERR_FAIL_INDEX_V(p_param,3,0);
- return shadow_param[p_param];
-}
-
void DirectionalLight::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shadow_mode","mode"),&DirectionalLight::set_shadow_mode);
- ObjectTypeDB::bind_method(_MD("get_shadow_mode"),&DirectionalLight::get_shadow_mode);
- ObjectTypeDB::bind_method(_MD("set_shadow_param","param","value"),&DirectionalLight::set_shadow_param);
- ObjectTypeDB::bind_method(_MD("get_shadow_param","param"),&DirectionalLight::get_shadow_param);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"shadow/mode",PROPERTY_HINT_ENUM,"Orthogonal,Perspective,PSSM 2 Splits,PSSM 4 Splits"),_SCS("set_shadow_mode"),_SCS("get_shadow_mode"));
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/max_distance",PROPERTY_HINT_EXP_RANGE,"0.00,99999,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_MAX_DISTANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/split_weight",PROPERTY_HINT_RANGE,"0.01,1.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_SPLIT_WEIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"shadow/zoffset_scale",PROPERTY_HINT_RANGE,"0.01,1024.0,0.01"),_SCS("set_shadow_param"),_SCS("get_shadow_param"), SHADOW_PARAM_PSSM_ZOFFSET_SCALE);
- BIND_CONSTANT( SHADOW_ORTHOGONAL );
- BIND_CONSTANT( SHADOW_PERSPECTIVE );
- BIND_CONSTANT( SHADOW_PARALLEL_2_SPLITS );
- BIND_CONSTANT( SHADOW_PARALLEL_4_SPLITS );
- BIND_CONSTANT( SHADOW_PARAM_MAX_DISTANCE );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_SPLIT_WEIGHT );
- BIND_CONSTANT( SHADOW_PARAM_PSSM_ZOFFSET_SCALE );
}
DirectionalLight::DirectionalLight() : Light( VisualServer::LIGHT_DIRECTIONAL ) {
- shadow_mode=SHADOW_ORTHOGONAL;
- shadow_param[SHADOW_PARAM_MAX_DISTANCE]=0;
- shadow_param[SHADOW_PARAM_PSSM_SPLIT_WEIGHT]=0.5;
- shadow_param[SHADOW_PARAM_PSSM_ZOFFSET_SCALE]=2.0;
}
@@ -658,19 +169,11 @@ DirectionalLight::DirectionalLight() : Light( VisualServer::LIGHT_DIRECTIONAL )
void OmniLight::_bind_methods() {
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
}
void SpotLight::_bind_methods() {
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/radius", PROPERTY_HINT_EXP_RANGE, "0.2,4096,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_RADIUS );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/attenuation", PROPERTY_HINT_EXP_EASING, "attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_ATTENUATION );
-
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_angle", PROPERTY_HINT_RANGE, "0.01,89.9,0.01"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ANGLE );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION );
-
}
diff --git a/scene/3d/light.h b/scene/3d/light.h
index b25c6a44b5..3c31d90d4c 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -44,57 +44,12 @@ class Light : public VisualInstance {
public:
- enum Parameter {
- PARAM_RADIUS=VisualServer::LIGHT_PARAM_RADIUS,
- PARAM_ENERGY=VisualServer::LIGHT_PARAM_ENERGY,
- PARAM_ATTENUATION=VisualServer::LIGHT_PARAM_ATTENUATION,
- PARAM_SPOT_ANGLE=VisualServer::LIGHT_PARAM_SPOT_ANGLE,
- PARAM_SPOT_ATTENUATION=VisualServer::LIGHT_PARAM_SPOT_ATTENUATION,
- PARAM_SHADOW_DARKENING=VisualServer::LIGHT_PARAM_SHADOW_DARKENING,
- PARAM_SHADOW_Z_OFFSET=VisualServer::LIGHT_PARAM_SHADOW_Z_OFFSET,
- PARAM_SHADOW_Z_SLOPE_SCALE=VisualServer::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE,
- PARAM_SHADOW_ESM_MULTIPLIER=VisualServer::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER,
- PARAM_SHADOW_BLUR_PASSES=VisualServer::LIGHT_PARAM_SHADOW_BLUR_PASSES,
- PARAM_MAX=VisualServer::LIGHT_PARAM_MAX
- };
- enum LightColor {
-
- COLOR_DIFFUSE=VisualServer::LIGHT_COLOR_DIFFUSE,
- COLOR_SPECULAR=VisualServer::LIGHT_COLOR_SPECULAR
- };
-
- enum BakeMode {
-
- BAKE_MODE_DISABLED,
- BAKE_MODE_INDIRECT,
- BAKE_MODE_INDIRECT_AND_SHADOWS,
- BAKE_MODE_FULL
-
- };
-
-
- enum Operator {
-
- OPERATOR_ADD,
- OPERATOR_SUB
- };
private:
-
- Ref<Texture> projector;
- float vars[PARAM_MAX];
- Color colors[3];
-
-
- BakeMode bake_mode;
- VisualServer::LightType type;
- bool shadows;
- bool enabled;
+ VS::LightType type;
bool editor_only;
- Operator op;
-
void _update_visibility();
// bind helpers
@@ -103,8 +58,7 @@ protected:
RID light;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
-
+
static void _bind_methods();
void _notification(int p_what);
@@ -114,44 +68,17 @@ public:
VS::LightType get_light_type() const { return type; }
- void set_parameter(Parameter p_var, float p_value);
- float get_parameter(Parameter p_var) const;
-
- void set_color(LightColor p_color,const Color& p_value);
- Color get_color(LightColor p_color) const;
-
- void set_project_shadows(bool p_enabled);
- bool has_project_shadows() const;
-
- void set_projector(const Ref<Texture>& p_projector);
- Ref<Texture> get_projector() const;
-
- void set_operator(Operator p_op);
- Operator get_operator() const;
-
- void set_bake_mode(BakeMode p_bake_mode);
- BakeMode get_bake_mode() const;
-
- void set_enabled(bool p_enabled);
- bool is_enabled() const;
-
void set_editor_only(bool p_editor_only);
bool is_editor_only() const;
virtual AABB get_aabb() const;
virtual DVector<Face3> get_faces(uint32_t p_usage_flags) const;
- void approximate_opengl_attenuation(float p_constant, float p_linear, float p_quadratic, float p_radius_treshold=0.5);
-
Light();
~Light();
};
-VARIANT_ENUM_CAST( Light::Parameter );
-VARIANT_ENUM_CAST( Light::LightColor );
-VARIANT_ENUM_CAST( Light::Operator );
-VARIANT_ENUM_CAST( Light::BakeMode);
class DirectionalLight : public Light {
@@ -160,39 +87,18 @@ class DirectionalLight : public Light {
public:
- enum ShadowMode {
- SHADOW_ORTHOGONAL,
- SHADOW_PERSPECTIVE,
- SHADOW_PARALLEL_2_SPLITS,
- SHADOW_PARALLEL_4_SPLITS
- };
- enum ShadowParam {
- SHADOW_PARAM_MAX_DISTANCE,
- SHADOW_PARAM_PSSM_SPLIT_WEIGHT,
- SHADOW_PARAM_PSSM_ZOFFSET_SCALE
- };
private:
- ShadowMode shadow_mode;
- float shadow_param[3];
+
+
protected:
static void _bind_methods();
public:
- void set_shadow_mode(ShadowMode p_mode);
- ShadowMode get_shadow_mode() const;
-
- void set_shadow_max_distance(float p_distance);
- float get_shadow_max_distance() const;
- void set_shadow_param(ShadowParam p_param, float p_value);
- float get_shadow_param(ShadowParam p_param) const;
DirectionalLight();
};
-VARIANT_ENUM_CAST( DirectionalLight::ShadowMode );
-VARIANT_ENUM_CAST( DirectionalLight::ShadowParam );
-
class OmniLight : public Light {
@@ -203,7 +109,7 @@ protected:
public:
- OmniLight() : Light( VisualServer::LIGHT_OMNI ) { set_parameter(PARAM_SHADOW_Z_OFFSET,0.001);}
+ OmniLight() : Light( VisualServer::LIGHT_OMNI ) { }
};
class SpotLight : public Light {
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 3ac5d8ed7b..994e329853 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -30,6 +30,7 @@
#include "servers/visual_server.h"
#include "scene/resources/surface_tool.h"
+#if 0
/*
static const char* _var_names[Particles::VAR_MAX]={
"vars/lifetime",
@@ -557,3 +558,4 @@ Particles::~Particles() {
VisualServer::get_singleton()->free(particles);
}
+#endif
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 42d27c41d7..fb3bb258ef 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -37,7 +37,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-
+#if 0
class Particles : public GeometryInstance {
public:
@@ -163,3 +163,4 @@ public:
VARIANT_ENUM_CAST( Particles::Variable );
#endif
+#endif
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 23bc64615d..131bbd7000 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -96,45 +96,6 @@ void Portal::_get_property_list( List<PropertyInfo> *p_list) const {
}
-RES Portal::_get_gizmo_geometry() const {
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(1.0,0.8,0.8,0.7) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- Vector<Point2> shape = get_shape();
-
- Vector2 center;
- for (int i=0;i<shape.size();i++) {
-
- int n=(i+1)%shape.size();
- Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( shape[i].x, shape[i].y,0 ));
- surface_tool->add_vertex( Vector3( shape[n].x, shape[n].y,0 ));
- center+=shape[i];
-
- }
-
- if (shape.size()>0) {
-
- center/=shape.size();
- Vector<Vector3> points;
- surface_tool->add_vertex( Vector3( center.x, center.y,0 ));
- surface_tool->add_vertex( Vector3( center.x, center.y,1.0 ));
- }
-
- return surface_tool->commit();
-}
-
AABB Portal::get_aabb() const {
@@ -178,18 +139,19 @@ void Portal::set_shape(const Vector<Point2>& p_shape) {
VisualServer::get_singleton()->portal_set_shape(portal, p_shape);
+ shape=p_shape;
update_gizmo();
}
Vector<Point2> Portal::get_shape() const {
- return VisualServer::get_singleton()->portal_get_shape(portal);
+ return shape;
}
void Portal::set_connect_range(float p_range) {
connect_range=p_range;
- VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
+ //VisualServer::get_singleton()->portal_set_connect_range(portal,p_range);
}
float Portal::get_connect_range() const {
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 149a56900f..8bcfa1ea4b 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -47,6 +47,7 @@ class Portal : public VisualInstance {
OBJ_TYPE(Portal, VisualInstance);
RID portal;
+ Vector<Point2> shape;
bool enabled;
float disable_distance;
@@ -55,7 +56,6 @@ class Portal : public VisualInstance {
AABB aabb;
- virtual RES _get_gizmo_geometry() const;
protected:
diff --git a/scene/3d/position_3d.cpp b/scene/3d/position_3d.cpp
index 27130cbe6a..de1a0b73f4 100644
--- a/scene/3d/position_3d.cpp
+++ b/scene/3d/position_3d.cpp
@@ -29,37 +29,6 @@
#include "position_3d.h"
#include "scene/resources/mesh.h"
-RES Position3D::_get_gizmo_geometry() const {
-
-
- Ref<Mesh> mesh = memnew( Mesh );
-
- DVector<Vector3> cursor_points;
- DVector<Color> cursor_colors;
- float cs = 0.25;
- cursor_points.push_back(Vector3(+cs,0,0));
- cursor_points.push_back(Vector3(-cs,0,0));
- cursor_points.push_back(Vector3(0,+cs,0));
- cursor_points.push_back(Vector3(0,-cs,0));
- cursor_points.push_back(Vector3(0,0,+cs));
- cursor_points.push_back(Vector3(0,0,-cs));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(1,0.5,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,1,0.5,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
- cursor_colors.push_back(Color(0.5,0.5,1,1));
-
- Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_line_width(3);
- Array d;
- d[Mesh::ARRAY_VERTEX]=cursor_points;
- d[Mesh::ARRAY_COLOR]=cursor_colors;
- mesh->add_surface(Mesh::PRIMITIVE_LINES,d);
- mesh->surface_set_material(0,mat);
- return mesh;
-}
Position3D::Position3D()
{
diff --git a/scene/3d/position_3d.h b/scene/3d/position_3d.h
index 6bac540fcb..676f46c2ee 100644
--- a/scene/3d/position_3d.h
+++ b/scene/3d/position_3d.h
@@ -35,7 +35,6 @@ class Position3D : public Spatial {
OBJ_TYPE(Position3D,Spatial);
- virtual RES _get_gizmo_geometry() const;
public:
diff --git a/scene/3d/quad.cpp b/scene/3d/quad.cpp
index 1a7eeef180..f31d248ba7 100644
--- a/scene/3d/quad.cpp
+++ b/scene/3d/quad.cpp
@@ -120,7 +120,7 @@ void Quad::_update() {
} else {
configured=true;
}
- VS::get_singleton()->mesh_add_surface(mesh,VS::PRIMITIVE_TRIANGLES,arr);
+ VS::get_singleton()->mesh_add_surface_from_arrays(mesh,VS::PRIMITIVE_TRIANGLES,arr);
pending_update=false;
}
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 9e6867d2a2..080fa880ba 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -75,50 +75,6 @@ void Room::_notification(int p_what) {
}
-RES Room::_get_gizmo_geometry() const {
-
- DVector<Face3> faces;
- if (!room.is_null())
- faces=room->get_geometry_hint();
-
- int count=faces.size();
- if (count==0)
- return RES();
-
- DVector<Face3>::Read facesr=faces.read();
-
- const Face3* facesptr=facesr.ptr();
-
- DVector<Vector3> points;
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.2,0.8,0.9,0.3) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
- for (int i=0;i<count;i++) {
-
- surface_tool->add_vertex(facesptr[i].vertex[0]);
- surface_tool->add_vertex(facesptr[i].vertex[1]);
-
- surface_tool->add_vertex(facesptr[i].vertex[1]);
- surface_tool->add_vertex(facesptr[i].vertex[2]);
-
- surface_tool->add_vertex(facesptr[i].vertex[2]);
- surface_tool->add_vertex(facesptr[i].vertex[0]);
-
- }
-
- return surface_tool->commit();
-}
@@ -127,8 +83,9 @@ AABB Room::get_aabb() const {
if (room.is_null())
return AABB();
- return room->get_bounds().get_aabb();
+ return AABB();
}
+
DVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
return DVector<Face3>();
@@ -154,9 +111,6 @@ void Room::set_room( const Ref<RoomBounds>& p_room ) {
propagate_notification(NOTIFICATION_AREA_CHANGED);
update_gizmo();
- if (room.is_valid())
- SpatialSoundServer::get_singleton()->room_set_bounds(sound_room,room->get_bounds());
-
}
@@ -202,32 +156,6 @@ void Room::_parse_node_faces(DVector<Face3> &all_faces,const Node *p_node) const
}
-void Room::compute_room_from_subtree() {
-
-
- DVector<Face3> all_faces;
- _parse_node_faces(all_faces,this);
-
-
- if (all_faces.size()==0)
- return;
- float error;
- DVector<Face3> wrapped_faces = Geometry::wrap_geometry(all_faces,&error);
-
-
- if (wrapped_faces.size()==0)
- return;
-
- BSP_Tree tree(wrapped_faces,error);
-
- Ref<RoomBounds> room( memnew( RoomBounds ) );
- room->set_bounds(tree);
- room->set_geometry_hint(wrapped_faces);
-
- set_room(room);
-
-}
-
void Room::set_simulate_acoustics(bool p_enable) {
@@ -268,7 +196,6 @@ void Room::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_room","room:Room"),&Room::set_room );
ObjectTypeDB::bind_method(_MD("get_room:Room"),&Room::get_room );
- ObjectTypeDB::bind_method(_MD("compute_room_from_subtree"),&Room::compute_room_from_subtree);
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index c7df4ceadd..346e687d9e 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -45,6 +45,8 @@
*/
+
+
class Room : public VisualInstance {
OBJ_TYPE( Room, VisualInstance );
@@ -65,7 +67,7 @@ private:
void _bounds_changed();
- virtual RES _get_gizmo_geometry() const;
+
protected:
@@ -89,7 +91,6 @@ public:
void set_simulate_acoustics(bool p_enable);
bool is_simulating_acoustics() const;
- void compute_room_from_subtree();
RID get_sound_room() const;
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index c996a8123c..96233c5ed7 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -163,7 +163,7 @@ void Skeleton::_notification(int p_what) {
Bone *bonesptr=&bones[0];
int len=bones.size();
- vs->skeleton_resize( skeleton, len ); // if same size, nothin really happens
+ vs->skeleton_allocate( skeleton, len ); // if same size, nothin really happens
// pose changed, rebuild cache of inverses
if (rest_global_inverse_dirty) {
@@ -513,51 +513,6 @@ void Skeleton::_make_dirty() {
}
-RES Skeleton::_get_gizmo_geometry() const {
-
- if (!GLOBAL_DEF("debug/draw_skeleton", true))
- return RES();
-
- if (bones.size()==0)
- return RES();
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.6,1.0,0.3,0.1) );
- mat->set_line_width(4);
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
- mat->set_flag(Material::FLAG_UNSHADED,true);
- mat->set_flag(Material::FLAG_ONTOP,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_LINES);
- surface_tool->set_material(mat);
-
-
- const Bone *bonesptr=&bones[0];
- int len=bones.size();
-
- for (int i=0;i<len;i++) {
-
- const Bone &b=bonesptr[i];
-
- Transform t;
- if (b.parent<0)
- continue;
-
- Vector3 v1=(bonesptr[b.parent].pose_global * bonesptr[b.parent].rest_global_inverse).xform(bonesptr[b.parent].rest_global_inverse.affine_inverse().origin);
- Vector3 v2=(b.pose_global * b.rest_global_inverse).xform(b.rest_global_inverse.affine_inverse().origin);
-
- surface_tool->add_vertex(v1);
- surface_tool->add_vertex(v2);
-
- }
-
- return surface_tool->commit();
-
-}
void Skeleton::localize_rests() {
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index bfdb1d1499..1b8136b06c 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -84,7 +84,6 @@ class Skeleton : public Spatial {
return bound;
}
- virtual RES _get_gizmo_geometry() const;
protected:
diff --git a/scene/3d/spatial_player.cpp b/scene/3d/spatial_player.cpp
index c7cf03e284..70370c51e7 100644
--- a/scene/3d/spatial_player.cpp
+++ b/scene/3d/spatial_player.cpp
@@ -88,146 +88,6 @@ bool SpatialPlayer::_can_gizmo_scale() const {
return false;
}
-RES SpatialPlayer::_get_gizmo_geometry() const {
-
- Ref<SurfaceTool> surface_tool( memnew( SurfaceTool ));
-
- Ref<FixedMaterial> mat( memnew( FixedMaterial ));
-
- mat->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.0,0.6,0.7,0.05) );
- mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
- mat->set_blend_mode( Material::BLEND_MODE_ADD );
- mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
-// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
-
-
- surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- surface_tool->set_material(mat);
-
- int sides=16;
- int sections=24;
-
-// float len=1;
- float deg=Math::deg2rad(params[PARAM_EMISSION_CONE_DEGREES]);
- if (deg==180)
- deg=179.5;
-
- Vector3 to=Vector3(0,0,-1);
-
- for(int j=0;j<sections;j++) {
-
- Vector3 p1=Matrix3(Vector3(1,0,0),deg*j/sections).xform(to);
- Vector3 p2=Matrix3(Vector3(1,0,0),deg*(j+1)/sections).xform(to);
-
- for(int i=0;i<sides;i++) {
-
- Vector3 p1r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p1);
- Vector3 p1s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p1);
- Vector3 p2s = Matrix3(Vector3(0,0,1),Math_PI*2*float(i+1)/sides).xform(p2);
- Vector3 p2r = Matrix3(Vector3(0,0,1),Math_PI*2*float(i)/sides).xform(p2);
-
- surface_tool->add_normal(p1r.normalized());
- surface_tool->add_vertex(p1r);
- surface_tool->add_normal(p1s.normalized());
- surface_tool->add_vertex(p1s);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
-
- surface_tool->add_normal(p1r.normalized());
- surface_tool->add_vertex(p1r);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
- surface_tool->add_normal(p2r.normalized());
- surface_tool->add_vertex(p2r);
-
- if (j==sections-1) {
-
- surface_tool->add_normal(p2r.normalized());
- surface_tool->add_vertex(p2r);
- surface_tool->add_normal(p2s.normalized());
- surface_tool->add_vertex(p2s);
- surface_tool->add_normal(Vector3(0,0,1));
- surface_tool->add_vertex(Vector3());
- }
- }
- }
-
-
- Ref<Mesh> mesh = surface_tool->commit();
-
- Ref<FixedMaterial> mat_speaker( memnew( FixedMaterial ));
-
- mat_speaker->set_parameter( FixedMaterial::PARAM_DIFFUSE,Color(0.3,0.3,0.6) );
- mat_speaker->set_parameter( FixedMaterial::PARAM_SPECULAR,Color(0.5,0.5,0.6) );
- //mat_speaker->set_blend_mode( Material::BLEND_MODE_MIX);
- //mat_speaker->set_flag(Material::FLAG_DOUBLE_SIDED,false);
- //mat_speaker->set_flag(Material::FLAG_UNSHADED,true);
-
- surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
- surface_tool->set_material(mat_speaker);
-
-// float radius=1;
-
-
- const int speaker_points=8;
- Vector3 speaker[speaker_points]={
- Vector3(0,0,1)*0.15,
- Vector3(1,1,1)*0.15,
- Vector3(1,1,0)*0.15,
- Vector3(2,2,-1)*0.15,
- Vector3(1,1,-1)*0.15,
- Vector3(0.8,0.8,-1.2)*0.15,
- Vector3(0.5,0.5,-1.4)*0.15,
- Vector3(0.0,0.0,-1.6)*0.15
- };
-
- int speaker_sides=10;
-
-
- for(int i = 0; i < speaker_sides ; i++) {
-
-
- Matrix3 ma(Vector3(0,0,1),Math_PI*2*float(i)/speaker_sides);
- Matrix3 mb(Vector3(0,0,1),Math_PI*2*float(i+1)/speaker_sides);
-
-
- for(int j=0;j<speaker_points-1;j++) {
-
- Vector3 points[4]={
- ma.xform(speaker[j]),
- mb.xform(speaker[j]),
- mb.xform(speaker[j+1]),
- ma.xform(speaker[j+1]),
- };
-
- Vector3 n = -Plane(points[0],points[1],points[2]).normal;
-
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[0]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[2]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[1]);
-
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[0]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[3]);
- surface_tool->add_normal(n);
- surface_tool->add_vertex(points[2]);
-
-
- }
-
-
- }
-
-
- return surface_tool->commit(mesh);
-
-}
-
-
void SpatialPlayer::_bind_methods() {
diff --git a/scene/3d/spatial_player.h b/scene/3d/spatial_player.h
index 5a8687b854..594fc8f850 100644
--- a/scene/3d/spatial_player.h
+++ b/scene/3d/spatial_player.h
@@ -60,7 +60,7 @@ private:
RID source_rid;
virtual bool _can_gizmo_scale() const;
- virtual RES _get_gizmo_geometry() const;
+
protected:
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index b4f7a4e5b4..5bc332f8fb 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -52,7 +52,7 @@ void VisualInstance::_notification(int p_what) {
Room *room=NULL;
bool is_geom = cast_to<GeometryInstance>();
- while(parent) {
+ /* while(parent) {
room = parent->cast_to<Room>();
if (room)
@@ -64,7 +64,7 @@ void VisualInstance::_notification(int p_what) {
}
parent=parent->get_parent_spatial();
- }
+ }*/
@@ -92,7 +92,7 @@ void VisualInstance::_notification(int p_what) {
VisualServer::get_singleton()->instance_set_scenario( instance, RID() );
VisualServer::get_singleton()->instance_set_room(instance,RID());
VisualServer::get_singleton()->instance_attach_skeleton( instance, RID() );
- VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
+ // VS::get_singleton()->instance_geometry_set_baked_light_sampler(instance, RID() );
} break;
@@ -172,30 +172,55 @@ Ref<Material> GeometryInstance::get_material_override() const{
-void GeometryInstance::set_draw_range_begin(float p_dist){
+void GeometryInstance::set_lod_min_distance(float p_dist){
+
+ lod_min_distance=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
+}
+
+float GeometryInstance::get_lod_min_distance() const{
+
+ return lod_min_distance;
+}
+
+
+void GeometryInstance::set_lod_max_distance(float p_dist) {
+
+ lod_max_distance=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
- draw_begin=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
}
-float GeometryInstance::get_draw_range_begin() const{
+float GeometryInstance::get_lod_max_distance() const {
- return draw_begin;
+ return lod_max_distance;
}
+void GeometryInstance::set_lod_min_hysteresis(float p_dist){
-void GeometryInstance::set_draw_range_end(float p_dist) {
+ lod_min_hysteresis=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
+}
- draw_end=p_dist;
- VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),draw_begin,draw_end);
+float GeometryInstance::get_lod_min_hysteresis() const{
+ return lod_min_hysteresis;
}
-float GeometryInstance::get_draw_range_end() const {
- return draw_end;
+void GeometryInstance::set_lod_max_hysteresis(float p_dist) {
+
+ lod_max_hysteresis=p_dist;
+ VS::get_singleton()->instance_geometry_set_draw_range(get_instance(),lod_min_distance,lod_max_distance,lod_min_hysteresis,lod_max_hysteresis);
+
}
+float GeometryInstance::get_lod_max_hysteresis() const {
+
+ return lod_max_hysteresis;
+}
+
+
void GeometryInstance::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_WORLD) {
@@ -212,8 +237,8 @@ void GeometryInstance::_notification(int p_what) {
if (flags[FLAG_USE_BAKED_LIGHT]) {
if (baked_light_instance) {
- baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
- baked_light_instance=NULL;
+ // baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
+ // baked_light_instance=NULL;
}
_baked_light_changed();
@@ -229,15 +254,15 @@ void GeometryInstance::_notification(int p_what) {
void GeometryInstance::_baked_light_changed() {
- if (!baked_light_instance)
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
- else
- VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
+ //if (!baked_light_instance)
+ // VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID());
+// else
+// VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance());
}
void GeometryInstance::_find_baked_light() {
-
+/*
Node *n=get_parent();
while(n) {
@@ -255,6 +280,7 @@ void GeometryInstance::_find_baked_light() {
}
_baked_light_changed();
+ */
}
void GeometryInstance::_update_visibility() {
@@ -288,7 +314,7 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
}
if (p_flag==FLAG_USE_BAKED_LIGHT) {
- if (is_inside_world()) {
+ /* if (is_inside_world()) {
if (!p_value) {
if (baked_light_instance) {
baked_light_instance->disconnect(SceneStringNames::get_singleton()->baked_light_changed,this,SceneStringNames::get_singleton()->_baked_light_changed);
@@ -298,7 +324,7 @@ void GeometryInstance::set_flag(Flags p_flag,bool p_value) {
} else {
_find_baked_light();
}
- }
+ }*/
}
}
@@ -333,8 +359,8 @@ GeometryInstance::ShadowCastingSetting GeometryInstance::get_cast_shadows_settin
void GeometryInstance::set_baked_light_texture_id(int p_id) {
- baked_light_texture_id=p_id;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),baked_light_texture_id);
+// baked_light_texture_id=p_id;
+// VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),baked_light_texture_id);
}
@@ -366,11 +392,18 @@ void GeometryInstance::_bind_methods() {
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);
+ ObjectTypeDB::bind_method(_MD("set_lod_max_hysteresis","mode"), &GeometryInstance::set_lod_max_hysteresis);
+ ObjectTypeDB::bind_method(_MD("get_lod_max_hysteresis"), &GeometryInstance::get_lod_max_hysteresis);
+
+ ObjectTypeDB::bind_method(_MD("set_lod_max_distance","mode"), &GeometryInstance::set_lod_max_distance);
+ ObjectTypeDB::bind_method(_MD("get_lod_max_distance"), &GeometryInstance::get_lod_max_distance);
+
+ ObjectTypeDB::bind_method(_MD("set_lod_min_hysteresis","mode"), &GeometryInstance::set_lod_min_hysteresis);
+ ObjectTypeDB::bind_method(_MD("get_lod_min_hysteresis"), &GeometryInstance::get_lod_min_hysteresis);
+
+ ObjectTypeDB::bind_method(_MD("set_lod_min_distance","mode"), &GeometryInstance::set_lod_min_distance);
+ ObjectTypeDB::bind_method(_MD("get_lod_min_distance"), &GeometryInstance::get_lod_min_distance);
- ObjectTypeDB::bind_method(_MD("set_draw_range_end","mode"), &GeometryInstance::set_draw_range_end);
- ObjectTypeDB::bind_method(_MD("get_draw_range_end"), &GeometryInstance::get_draw_range_end);
ObjectTypeDB::bind_method(_MD("set_baked_light_texture_id","id"), &GeometryInstance::set_baked_light_texture_id);
ObjectTypeDB::bind_method(_MD("get_baked_light_texture_id"), &GeometryInstance::get_baked_light_texture_id);
@@ -385,9 +418,6 @@ 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_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"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "geometry/extra_cull_margin",PROPERTY_HINT_RANGE,"0,16384,0"), _SCS("set_extra_cull_margin"), _SCS("get_extra_cull_margin"));
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/billboard_y"), _SCS("set_flag"), _SCS("get_flag"),FLAG_BILLBOARD_FIX_Y);
@@ -395,12 +425,15 @@ void GeometryInstance::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/visible_in_all_rooms"), _SCS("set_flag"), _SCS("get_flag"),FLAG_VISIBLE_IN_ALL_ROOMS);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "geometry/use_baked_light"), _SCS("set_flag"), _SCS("get_flag"),FLAG_USE_BAKED_LIGHT);
ADD_PROPERTY( PropertyInfo( Variant::INT, "geometry/baked_light_tex_id"), _SCS("set_baked_light_texture_id"), _SCS("get_baked_light_texture_id"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod/min_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_distance"), _SCS("get_lod_min_distance"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod/min_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_min_hysteresis"), _SCS("get_lod_min_hysteresis"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod/max_distance",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_distance"), _SCS("get_lod_max_distance"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "lod/max_hysteresis",PROPERTY_HINT_RANGE,"0,32768,0.01"), _SCS("set_lod_max_hysteresis"), _SCS("get_lod_max_hysteresis"));
// ADD_SIGNAL( MethodInfo("visibility_changed"));
BIND_CONSTANT(FLAG_VISIBLE );
BIND_CONSTANT(FLAG_CAST_SHADOW );
- BIND_CONSTANT(FLAG_RECEIVE_SHADOWS );
BIND_CONSTANT(FLAG_BILLBOARD );
BIND_CONSTANT(FLAG_BILLBOARD_FIX_Y );
BIND_CONSTANT(FLAG_DEPH_SCALE );
@@ -415,20 +448,23 @@ void GeometryInstance::_bind_methods() {
}
GeometryInstance::GeometryInstance() {
- draw_begin=0;
- draw_end=0;
+ lod_min_distance=0;
+ lod_max_distance=0;
+ lod_min_hysteresis=0;
+ lod_max_hysteresis=0;
+
for(int i=0;i<FLAG_MAX;i++) {
flags[i]=false;
}
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;
- VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
+// VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
}
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index e286d5fa88..eb0587815f 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -89,7 +89,6 @@ public:
enum Flags {
FLAG_VISIBLE=VS::INSTANCE_FLAG_VISIBLE,
FLAG_CAST_SHADOW=VS::INSTANCE_FLAG_CAST_SHADOW,
- FLAG_RECEIVE_SHADOWS=VS::INSTANCE_FLAG_RECEIVE_SHADOWS,
FLAG_BILLBOARD=VS::INSTANCE_FLAG_BILLBOARD,
FLAG_BILLBOARD_FIX_Y=VS::INSTANCE_FLAG_BILLBOARD_FIX_Y,
FLAG_DEPH_SCALE=VS::INSTANCE_FLAG_DEPH_SCALE,
@@ -110,8 +109,10 @@ private:
bool flags[FLAG_MAX];
ShadowCastingSetting shadow_casting_setting;
Ref<Material> material_override;
- float draw_begin;
- float draw_end;
+ float lod_min_distance;
+ float lod_max_distance;
+ float lod_min_hysteresis;
+ float lod_max_hysteresis;
void _find_baked_light();
BakedLightInstance *baked_light_instance;
int baked_light_texture_id;
@@ -131,11 +132,17 @@ public:
void set_cast_shadows_setting(ShadowCastingSetting p_shadow_casting_setting);
ShadowCastingSetting get_cast_shadows_setting() const;
- void set_draw_range_begin(float p_dist);
- float get_draw_range_begin() const;
+ void set_lod_min_distance(float p_dist);
+ float get_lod_min_distance() const;
- void set_draw_range_end(float p_dist);
- float get_draw_range_end() const;
+ void set_lod_max_distance(float p_dist);
+ float get_lod_max_distance() const;
+
+ void set_lod_min_hysteresis(float p_dist);
+ float get_lod_min_hysteresis() const;
+
+ void set_lod_max_hysteresis(float p_dist);
+ float get_lod_max_hysteresis() const;
void set_material_override(const Ref<Material>& p_material);
Ref<Material> get_material_override() const;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 5e66544153..27bdb581e1 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -59,6 +59,10 @@ void ColorPicker::_notification(int p_what) {
w_material->set_shader(get_shader("w_editor"));
update_material(uv_material,color,h,s,v);
update_material(w_material,color,h,s,v);
+ uv_edit->set_texture(get_icon("color_main"));
+ w_edit->set_texture(get_icon("color_hue"));
+ sample->set_texture(get_icon("color_sample"));
+
_update_controls();
} break;
@@ -192,10 +196,24 @@ void ColorPicker::_update_presets()
{
Size2 size=bt_add_preset->get_size();
preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height));
- Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB);
- for (int y=0;y<size.y;y++)
- for (int x=0;x<size.x*presets.size();x++)
- i.put_pixel(x,y,presets[(int)x/size.x]);
+
+ DVector<uint8_t> img;
+ img.resize(size.x*presets.size()*size.y*3);
+
+ {
+ DVector<uint8_t>::Write w=img.write();
+ for (int y=0;y<size.y;y++) {
+ for (int x=0;x<size.x*presets.size();x++) {
+ int ofs = (y*(size.x*presets.size())+x)*3;
+ w[ofs+0]=uint8_t(CLAMP(presets[(int)x/size.x].r*255.0,0,255));
+ w[ofs+1]=uint8_t(CLAMP(presets[(int)x/size.x].g*255.0,0,255));
+ w[ofs+2]=uint8_t(CLAMP(presets[(int)x/size.x].b*255.0,0,255));
+ }
+ }
+ }
+
+ Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB8,img);
+
Ref<ImageTexture> t;
t.instance();
t->create_from_image(i);
@@ -394,15 +412,23 @@ void ColorPicker::_screen_input(const InputEvent &ev)
} else if (ev.type==InputEvent::MOUSE_MOTION) {
const InputEventMouse &mev = ev.mouse_motion;
Viewport *r=get_tree()->get_root();
- if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y)))
+ if (!r->get_visible_rect().has_point(Point2(mev.global_x,mev.global_y)))
return;
Image img =r->get_screen_capture();
if (!img.empty()) {
last_capture=img;
r->queue_screen_capture();
}
- if (!last_capture.empty())
- set_color(last_capture.get_pixel(mev.global_x,mev.global_y));
+ if (!last_capture.empty()) {
+ int pw = last_capture.get_format()==Image::FORMAT_RGBA8?4:3;
+ int ofs = (mev.global_y*last_capture.get_width()+mev.global_x)*pw;
+
+ DVector<uint8_t>::Read r = last_capture.get_data().read();
+
+ Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 );
+
+ set_color(c);
+ }
}
}
@@ -474,16 +500,10 @@ ColorPicker::ColorPicker() :
HBoxContainer *hb_edit = memnew( HBoxContainer );
uv_edit= memnew ( TextureFrame );
- Image i(256, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<256;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> t;
- t.instance();
- t->create_from_image(i);
- uv_edit->set_texture(t);
+
+
+
uv_edit->set_ignore_mouse(false);
- uv_edit->set_custom_minimum_size(Size2(256,256));
uv_edit->connect("input_event", this, "_uv_input");
Control *c= memnew( Control );
uv_edit->add_child(c);
@@ -497,16 +517,9 @@ ColorPicker::ColorPicker() :
add_child(hb_edit);
w_edit= memnew( TextureFrame );
- i = Image(15, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<15;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> tw;
- tw.instance();
- tw->create_from_image(i);
- w_edit->set_texture(tw);
- w_edit->set_ignore_mouse(false);
- w_edit->set_custom_minimum_size(Size2(15,256));
+
+
+ w_edit->set_ignore_mouse(false);
w_edit->connect("input_event", this, "_w_input");
c= memnew( Control );
w_edit->add_child(c);
@@ -594,17 +607,6 @@ ColorPicker::ColorPicker() :
set_color(Color(1,1,1));
- i.create(256,20,false,Image::FORMAT_RGB);
- for (int y=0;y<20;y++)
- for(int x=0;x<256;x++)
- if ((x/4+y/4)%2)
- i.put_pixel(x,y,Color(1,1,1));
- else
- i.put_pixel(x,y,Color(0.6,0.6,0.6));
- Ref<ImageTexture> t_smpl;
- t_smpl.instance();
- t_smpl->create_from_image(i);
- sample->set_texture(t_smpl);
HBoxContainer *bbc = memnew( HBoxContainer );
add_child(bbc);
diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_frame.cpp
index 9ad6398359..ed1abbadee 100644
--- a/scene/gui/patch_9_frame.cpp
+++ b/scene/gui/patch_9_frame.cpp
@@ -39,7 +39,7 @@ void Patch9Frame::_notification(int p_what) {
Size2 s=get_size();
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_style_box(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
+ VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center,modulate);
// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
/*
diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp
index 8e238c7d77..9ee0cf9349 100644
--- a/scene/main/canvas_layer.cpp
+++ b/scene/main/canvas_layer.cpp
@@ -246,6 +246,15 @@ Node* CanvasLayer::get_custom_viewport() const {
return custom_viewport;
}
+void CanvasLayer::reset_sort_index() {
+ sort_index=0;
+}
+
+int CanvasLayer::get_sort_index() {
+
+ return sort_index++;
+}
+
void CanvasLayer::_bind_methods() {
@@ -296,4 +305,5 @@ CanvasLayer::CanvasLayer() {
canvas = Ref<World2D>( memnew(World2D) );
custom_viewport=NULL;
custom_viewport_id=0;
+ sort_index=0;
}
diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h
index a1311390be..bb63c96cdf 100644
--- a/scene/main/canvas_layer.h
+++ b/scene/main/canvas_layer.h
@@ -52,6 +52,8 @@ class CanvasLayer : public Node {
RID viewport;
Viewport *vp;
+ int sort_index;
+
// Deprecated, should be removed in a future version.
void _set_rotationd(real_t p_rotation);
real_t _get_rotationd() const;
@@ -93,6 +95,9 @@ public:
void set_custom_viewport(Node *p_viewport);
Node* get_custom_viewport() const;
+ void reset_sort_index();
+ int get_sort_index();
+
CanvasLayer();
};
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 1892240426..5d4e46f9ac 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -315,6 +315,12 @@ void Node::move_child(Node *p_child,int p_pos) {
}
+ if (p_child->data.pos==p_pos)
+ return; //do nothing
+
+ int motion_from = MIN(p_pos,p_child->data.pos);
+ int motion_to = MAX(p_pos,p_child->data.pos);
+
data.children.remove( p_child->data.pos );
data.children.insert( p_pos, p_child );
@@ -324,13 +330,13 @@ void Node::move_child(Node *p_child,int p_pos) {
data.blocked++;
//new pos first
- for (int i=0;i<data.children.size();i++) {
+ for (int i=motion_from;i<=motion_to;i++) {
data.children[i]->data.pos=i;
}
// notification second
move_child_notify(p_child);
- for (int i=0;i<data.children.size();i++) {
+ for (int i=motion_from;i<=motion_to;i++) {
data.children[i]->notification( NOTIFICATION_MOVED_IN_PARENT );
}
diff --git a/scene/main/scene_main_loop.cpp b/scene/main/scene_main_loop.cpp
index e3472c074a..c1552a4167 100644
--- a/scene/main/scene_main_loop.cpp
+++ b/scene/main/scene_main_loop.cpp
@@ -746,11 +746,11 @@ Ref<Material> SceneTree::get_debug_navigation_material() {
return navigation_material;
Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+/* line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_color());*/
navigation_material=line_material;
@@ -764,11 +764,11 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material(){
return navigation_disabled_material;
Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+/* line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_navigation_disabled_color());*/
navigation_disabled_material=line_material;
@@ -782,11 +782,11 @@ Ref<Material> SceneTree::get_debug_collision_material() {
Ref<FixedMaterial> line_material = Ref<FixedMaterial>( memnew( FixedMaterial ));
- line_material->set_flag(Material::FLAG_UNSHADED, true);
+ /*line_material->set_flag(Material::FLAG_UNSHADED, true);
line_material->set_line_width(3.0);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
line_material->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY, true);
- line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collisions_color());
+ line_material->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collisions_color());*/
collision_material=line_material;
@@ -801,10 +801,10 @@ Ref<Mesh> SceneTree::get_debug_contact_mesh() {
debug_contact_mesh = Ref<Mesh>( memnew( Mesh ) );
Ref<FixedMaterial> mat = memnew( FixedMaterial );
- mat->set_flag(Material::FLAG_UNSHADED,true);
+ /*mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
- mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());
+ mat->set_parameter(FixedMaterial::PARAM_DIFFUSE,get_debug_collision_contact_color());*/
Vector3 diamond[6]={
Vector3(-1, 0, 0),
@@ -1098,7 +1098,11 @@ void SceneTree::_update_root_rect() {
if (stretch_mode==STRETCH_MODE_DISABLED) {
- root->set_rect(Rect2(Point2(),last_screen_size));
+
+ root->set_size(last_screen_size);
+ root->set_attach_to_screen_rect(Rect2(Point2(),last_screen_size));
+ root->set_size_override_stretch(false);
+ root->set_size_override(false,Size2());
return; //user will take care
}
@@ -1174,21 +1178,18 @@ void SceneTree::_update_root_rect() {
switch (stretch_mode) {
case STRETCH_MODE_2D: {
-// root->set_rect(Rect2(Point2(),video_mode));
- root->set_as_render_target(false);
- root->set_rect(Rect2(margin,screen_size));
+ root->set_size(screen_size);
+ root->set_attach_to_screen_rect(Rect2(margin,screen_size));
root->set_size_override_stretch(true);
root->set_size_override(true,viewport_size);
} break;
case STRETCH_MODE_VIEWPORT: {
- root->set_rect(Rect2(Point2(),viewport_size));
+ root->set_size(viewport_size);
+ root->set_attach_to_screen_rect(Rect2(margin,screen_size));
root->set_size_override_stretch(false);
root->set_size_override(false,Size2());
- root->set_as_render_target(true);
- root->set_render_target_update_mode(Viewport::RENDER_TARGET_UPDATE_ALWAYS);
- root->set_render_target_to_screen_rect(Rect2(margin,screen_size));
} break;
@@ -2300,7 +2301,7 @@ SceneTree::SceneTree() {
stretch_aspect=STRETCH_ASPECT_IGNORE;
last_screen_size=Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height );
- root->set_rect(Rect2(Point2(),last_screen_size));
+ root->set_size(last_screen_size);
if (ScriptDebugger::get_singleton()) {
ScriptDebugger::get_singleton()->set_request_scene_tree_message_func(_debugger_request_tree,this);
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index b22d1fcdf4..44a3f41a4a 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -54,22 +54,22 @@
int RenderTargetTexture::get_width() const {
ERR_FAIL_COND_V(!vp,0);
- return vp->rect.size.width;
+ return vp->size.width;
}
int RenderTargetTexture::get_height() const{
ERR_FAIL_COND_V(!vp,0);
- return vp->rect.size.height;
+ return vp->size.height;
}
Size2 RenderTargetTexture::get_size() const{
ERR_FAIL_COND_V(!vp,Size2());
- return vp->rect.size;
+ return vp->size;
}
RID RenderTargetTexture::get_rid() const{
ERR_FAIL_COND_V(!vp,RID());
- return vp->render_target_texture_rid;
+ return vp->texture_rid;
}
bool RenderTargetTexture::has_alpha() const{
@@ -85,7 +85,7 @@ void RenderTargetTexture::set_flags(uint32_t p_flags){
else
flags=0;
- VS::get_singleton()->texture_set_flags(vp->render_target_texture_rid,flags);
+ VS::get_singleton()->texture_set_flags(vp->texture_rid,flags);
}
@@ -141,9 +141,9 @@ void Viewport::_update_stretch_transform() {
if (size_override_stretch && size_override) {
//print_line("sive override size "+size_override_size);
- //print_line("rect size "+rect.size);
+ //print_line("rect size "+size);
stretch_transform=Matrix32();
- Size2 scale = rect.size/(size_override_size+size_override_margin*2);
+ Size2 scale = size/(size_override_size+size_override_margin*2);
stretch_transform.scale(scale);
stretch_transform.elements[2]=size_override_margin*scale;
@@ -164,14 +164,14 @@ void Viewport::_update_rect() {
return;
- if (!render_target && parent_control) {
+ /*if (!render_target && parent_control) {
Control *c = parent_control;
rect.pos=Point2();
rect.size=c->get_size();
- }
-
+ }*/
+/*
VisualServer::ViewportRect vr;
vr.x=rect.pos.x;
vr.y=rect.pos.y;
@@ -191,8 +191,8 @@ void Viewport::_update_rect() {
}
emit_signal("size_changed");
- render_target_texture->emit_changed();
-
+ texture->emit_changed();
+*/
}
@@ -232,12 +232,12 @@ void Viewport::_vp_enter_tree() {
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent_ci);
VisualServer::get_singleton()->canvas_item_set_visible(canvas_item,false);
- VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
+// VisualServer::get_singleton()->canvas_item_attach_viewport(canvas_item,viewport);
parent_control->connect("resized",this,"_parent_resized");
parent_control->connect("visibility_changed",this,"_parent_visibility_changed");
} else if (!parent){
- VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
+// VisualServer::get_singleton()->viewport_attach_to_screen(viewport,0);
}
@@ -246,6 +246,7 @@ void Viewport::_vp_enter_tree() {
void Viewport::_vp_exit_tree() {
+ /*
if (parent_control) {
parent_control->disconnect("resized",this,"_parent_resized");
@@ -268,7 +269,7 @@ void Viewport::_vp_exit_tree() {
VisualServer::get_singleton()->viewport_detach(viewport);
}
-
+*/
}
@@ -346,11 +347,6 @@ void Viewport::_notification(int p_what) {
parent_node=parent_node->get_parent();
}
-
- if (!render_target)
- _vp_enter_tree();
-
-
current_canvas=find_world_2d()->get_canvas();
VisualServer::get_singleton()->viewport_set_scenario(viewport,find_world()->get_scenario());
VisualServer::get_singleton()->viewport_attach_canvas(viewport,current_canvas);
@@ -370,7 +366,7 @@ void Viewport::_notification(int p_what) {
//3D
PhysicsServer::get_singleton()->space_set_debug_contacts(find_world()->get_space(),get_tree()->get_collision_debug_contact_count());
contact_3d_debug_multimesh=VisualServer::get_singleton()->multimesh_create();
- VisualServer::get_singleton()->multimesh_set_instance_count(contact_3d_debug_multimesh,get_tree()->get_collision_debug_contact_count());
+ VisualServer::get_singleton()->multimesh_allocate(contact_3d_debug_multimesh,get_tree()->get_collision_debug_contact_count(),VS::MULTIMESH_TRANSFORM_3D,VS::MULTIMESH_COLOR_8BIT);
VisualServer::get_singleton()->multimesh_set_visible_instances(contact_3d_debug_multimesh,0);
VisualServer::get_singleton()->multimesh_set_mesh(contact_3d_debug_multimesh,get_tree()->get_debug_contact_mesh()->get_rid());
contact_3d_debug_instance=VisualServer::get_singleton()->instance_create();
@@ -380,6 +376,7 @@ void Viewport::_notification(int p_what) {
}
+ VS::get_singleton()->viewport_set_active(viewport,true);
} break;
case NOTIFICATION_READY: {
#ifndef _3D_DISABLED
@@ -418,8 +415,8 @@ void Viewport::_notification(int p_what) {
if (world_2d.is_valid())
world_2d->_remove_viewport(this);
- if (!render_target)
- _vp_exit_tree();
+ //if (!render_target)
+ // _vp_exit_tree();
VisualServer::get_singleton()->viewport_set_scenario(viewport,RID());
SpatialSoundServer::get_singleton()->listener_set_space(internal_listener, RID());
@@ -439,6 +436,9 @@ void Viewport::_notification(int p_what) {
remove_from_group("_viewports");
parent_control=NULL;
+ VS::get_singleton()->viewport_set_active(viewport,false);
+
+
} break;
case NOTIFICATION_FIXED_PROCESS: {
@@ -452,7 +452,7 @@ void Viewport::_notification(int p_what) {
if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) {
VisualServer::get_singleton()->canvas_item_clear(contact_2d_debug);
- VisualServer::get_singleton()->canvas_item_raise(contact_2d_debug);
+ VisualServer::get_singleton()->canvas_item_set_draw_index(contact_2d_debug,0xFFFFF); //very high index
Vector<Vector2> points = Physics2DServer::get_singleton()->space_get_contacts(find_world_2d()->get_space());
int point_count = Physics2DServer::get_singleton()->space_get_contact_count(find_world_2d()->get_space());
@@ -488,13 +488,13 @@ void Viewport::_notification(int p_what) {
VisualServer::get_singleton()->multimesh_instance_set_transform(contact_3d_debug_multimesh,i,t);
}
aabb.grow(aabb.get_longest_axis_size()*0.01);
- VisualServer::get_singleton()->multimesh_set_aabb(contact_3d_debug_multimesh,aabb);
+ VisualServer::get_singleton()->multimesh_set_custom_aabb(contact_3d_debug_multimesh,aabb);
}
}
- if (physics_object_picking && (render_target || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
+ if (physics_object_picking && (to_screen_rect==Rect2() || Input::get_singleton()->get_mouse_mode()!=Input::MOUSE_MODE_CAPTURED)) {
Vector2 last_pos(1e20,1e20);
CollisionObject *last_object;
@@ -708,15 +708,18 @@ RID Viewport::get_viewport() const {
return viewport;
}
-void Viewport::set_rect(const Rect2& p_rect) {
+void Viewport::set_size(const Size2 &p_size) {
- if (rect==p_rect)
+ if (size==p_size.floor())
return;
- rect=p_rect;
+ size=p_size.floor();
+ VS::get_singleton()->viewport_set_size(viewport,size.width,size.height);
_update_rect();
_update_stretch_transform();
+ emit_signal("size_changed");
+
}
Rect2 Viewport::get_visible_rect() const {
@@ -724,12 +727,12 @@ Rect2 Viewport::get_visible_rect() const {
Rect2 r;
- if (rect.pos==Vector2() && rect.size==Size2()) {
+ if (size==Size2()) {
r=Rect2( Point2(), Size2( OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height ) );
} else {
- r=Rect2( rect.pos , rect.size );
+ r=Rect2( Point2() , size );
}
if (size_override) {
@@ -740,9 +743,9 @@ Rect2 Viewport::get_visible_rect() const {
return r;
}
-Rect2 Viewport::get_rect() const {
+Size2 Viewport::get_size() const {
- return rect;
+ return size;
}
@@ -1219,10 +1222,10 @@ bool Viewport::is_size_override_stretch_enabled() const {
return size_override_stretch;
}
-
+#if 0
void Viewport::set_as_render_target(bool p_enable){
- if (render_target==p_enable)
+/* if (render_target==p_enable)
return;
render_target=p_enable;
@@ -1238,117 +1241,114 @@ void Viewport::set_as_render_target(bool p_enable){
if (p_enable) {
- render_target_texture_rid = VS::get_singleton()->viewport_get_render_target_texture(viewport);
+ texture_rid = VS::get_singleton()->viewport_get_texture(viewport);
} else {
- render_target_texture_rid=RID();
+ texture_rid=RID();
}
- render_target_texture->set_flags(render_target_texture->flags);
- render_target_texture->emit_changed();
+ texture->set_flags(texture->flags);
+ texture->emit_changed();
update_configuration_warning();
+ */
}
bool Viewport::is_set_as_render_target() const{
return render_target;
+
}
-void Viewport::set_render_target_update_mode(RenderTargetUpdateMode p_mode){
+#endif
+void Viewport::set_update_mode(UpdateMode p_mode){
- render_target_update_mode=p_mode;
- VS::get_singleton()->viewport_set_render_target_update_mode(viewport,VS::RenderTargetUpdateMode(p_mode));
+ update_mode=p_mode;
+// VS::get_singleton()->viewport_set_update_mode(viewport,VS::RenderTargetUpdateMode(p_mode));
}
-Viewport::RenderTargetUpdateMode Viewport::get_render_target_update_mode() const{
+Viewport::UpdateMode Viewport::get_update_mode() const{
- return render_target_update_mode;
+ return update_mode;
}
-//RID get_render_target_texture() const;
+//RID get_texture() const;
void Viewport::queue_screen_capture(){
- VS::get_singleton()->viewport_queue_screen_capture(viewport);
+ //VS::get_singleton()->viewport_queue_screen_capture(viewport);
}
Image Viewport::get_screen_capture() const {
- return VS::get_singleton()->viewport_get_screen_capture(viewport);
+// return VS::get_singleton()->viewport_get_screen_capture(viewport);
+ return Image();
}
-Ref<RenderTargetTexture> Viewport::get_render_target_texture() const {
+Ref<RenderTargetTexture> Viewport::get_texture() const {
- return render_target_texture;
+ return texture;
}
-void Viewport::set_render_target_vflip(bool p_enable) {
+void Viewport::set_vflip(bool p_enable) {
- render_target_vflip=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_vflip(viewport,p_enable);
+ vflip=p_enable;
+// VisualServer::get_singleton()->viewport_set_vflip(viewport,p_enable);
}
-bool Viewport::get_render_target_vflip() const{
+bool Viewport::get_vflip() const{
- return render_target_vflip;
+ return vflip;
}
-void Viewport::set_render_target_clear_on_new_frame(bool p_enable) {
+void Viewport::set_clear_on_new_frame(bool p_enable) {
- render_target_clear_on_new_frame=p_enable;
- VisualServer::get_singleton()->viewport_set_render_target_clear_on_new_frame(viewport,p_enable);
+ clear_on_new_frame=p_enable;
+ //VisualServer::get_singleton()->viewport_set_clear_on_new_frame(viewport,p_enable);
}
-bool Viewport::get_render_target_clear_on_new_frame() const{
+bool Viewport::get_clear_on_new_frame() const{
- return render_target_clear_on_new_frame;
+ return clear_on_new_frame;
}
-void Viewport::render_target_clear() {
+void Viewport::clear() {
- //render_target_clear=true;
- VisualServer::get_singleton()->viewport_render_target_clear(viewport);
+ //clear=true;
+// VisualServer::get_singleton()->viewport_clear(viewport);
}
-void Viewport::set_render_target_filter(bool p_enable) {
-
- if(!render_target)
- return;
+void Viewport::set_filter(bool p_enable) {
- render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
+ texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
}
-bool Viewport::get_render_target_filter() const{
+bool Viewport::get_filter() const{
- return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
+ return (texture->get_flags()&Texture::FLAG_FILTER)!=0;
}
-void Viewport::set_render_target_gen_mipmaps(bool p_enable) {
+void Viewport::set_gen_mipmaps(bool p_enable) {
- //render_target_texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
- render_target_gen_mipmaps=p_enable;
+ //texture->set_flags(p_enable?int(Texture::FLAG_FILTER):int(0));
+ gen_mipmaps=p_enable;
}
-bool Viewport::get_render_target_gen_mipmaps() const{
+bool Viewport::get_gen_mipmaps() const{
- //return (render_target_texture->get_flags()&Texture::FLAG_FILTER)!=0;
- return render_target_gen_mipmaps;
+ //return (texture->get_flags()&Texture::FLAG_FILTER)!=0;
+ return gen_mipmaps;
}
Matrix32 Viewport::_get_input_pre_xform() const {
Matrix32 pre_xf;
- if (render_target) {
- if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-to_screen_rect.pos;
- pre_xf.scale(rect.size/to_screen_rect.size);
- }
- } else {
+ if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-rect.pos;
+ pre_xf.elements[2]=-to_screen_rect.pos;
+ pre_xf.scale(size/to_screen_rect.size);
}
return pre_xf;
@@ -1457,7 +1457,7 @@ void Viewport::_vp_input(const InputEvent& p_ev) {
if (parent_control && !parent_control->is_visible())
return;
- if (render_target && to_screen_rect==Rect2())
+ if (to_screen_rect==Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
@@ -1483,7 +1483,7 @@ void Viewport::_vp_unhandled_input(const InputEvent& p_ev) {
if (parent_control && !parent_control->is_visible())
return;
- if (render_target && to_screen_rect==Rect2())
+ if (to_screen_rect==Rect2())
return; //if render target, can't get input events
//this one handles system input, p_ev are in system coordinates
@@ -2518,17 +2518,18 @@ bool Viewport::is_using_own_world() const {
return own_world.is_valid();
}
-void Viewport::set_render_target_to_screen_rect(const Rect2& p_rect) {
+void Viewport::set_attach_to_screen_rect(const Rect2& p_rect) {
+ VS::get_singleton()->viewport_attach_to_screen(viewport,p_rect);
to_screen_rect=p_rect;
- VisualServer::get_singleton()->viewport_set_render_target_to_screen_rect(viewport,to_screen_rect);
}
-Rect2 Viewport::get_render_target_to_screen_rect() const{
+Rect2 Viewport::get_attach_to_screen_rect() const{
return to_screen_rect;
}
+
void Viewport::set_physics_object_picking(bool p_enable) {
physics_object_picking=p_enable;
@@ -2584,19 +2585,28 @@ Control *Viewport::get_modal_stack_top() const {
String Viewport::get_configuration_warning() const {
- if (get_parent() && !get_parent()->cast_to<Control>() && !render_target) {
+ /*if (get_parent() && !get_parent()->cast_to<Control>() && !render_target) {
return TTR("This viewport is not set as render target. If you intend for it to display its contents directly to the screen, make it a child of a Control so it can obtain a size. Otherwise, make it a RenderTarget and assign its internal texture to some node for display.");
- }
+ }*/
return String();
}
+void Viewport::gui_reset_canvas_sort_index() {
+ gui.canvas_sort_index=0;
+}
+int Viewport::gui_get_canvas_sort_index() {
+
+ return gui.canvas_sort_index++;
+}
+
+
void Viewport::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_rect","rect"), &Viewport::set_rect);
- ObjectTypeDB::bind_method(_MD("get_rect"), &Viewport::get_rect);
+ ObjectTypeDB::bind_method(_MD("set_size","size"), &Viewport::set_size);
+ ObjectTypeDB::bind_method(_MD("get_size"), &Viewport::get_size);
ObjectTypeDB::bind_method(_MD("set_world_2d","world_2d:World2D"), &Viewport::set_world_2d);
ObjectTypeDB::bind_method(_MD("get_world_2d:World2D"), &Viewport::get_world_2d);
ObjectTypeDB::bind_method(_MD("find_world_2d:World2D"), &Viewport::find_world_2d);
@@ -2630,27 +2640,25 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("queue_screen_capture"), &Viewport::queue_screen_capture);
ObjectTypeDB::bind_method(_MD("get_screen_capture"), &Viewport::get_screen_capture);
- ObjectTypeDB::bind_method(_MD("set_as_render_target","enable"), &Viewport::set_as_render_target);
- ObjectTypeDB::bind_method(_MD("is_set_as_render_target"), &Viewport::is_set_as_render_target);
- ObjectTypeDB::bind_method(_MD("set_render_target_vflip","enable"), &Viewport::set_render_target_vflip);
- ObjectTypeDB::bind_method(_MD("get_render_target_vflip"), &Viewport::get_render_target_vflip);
+ ObjectTypeDB::bind_method(_MD("set_vflip","enable"), &Viewport::set_vflip);
+ ObjectTypeDB::bind_method(_MD("get_vflip"), &Viewport::get_vflip);
- ObjectTypeDB::bind_method(_MD("set_render_target_clear_on_new_frame","enable"), &Viewport::set_render_target_clear_on_new_frame);
- ObjectTypeDB::bind_method(_MD("get_render_target_clear_on_new_frame"), &Viewport::get_render_target_clear_on_new_frame);
+ ObjectTypeDB::bind_method(_MD("set_clear_on_new_frame","enable"), &Viewport::set_clear_on_new_frame);
+ ObjectTypeDB::bind_method(_MD("get_clear_on_new_frame"), &Viewport::get_clear_on_new_frame);
- ObjectTypeDB::bind_method(_MD("render_target_clear"), &Viewport::render_target_clear);
+ ObjectTypeDB::bind_method(_MD("clear"), &Viewport::clear);
- ObjectTypeDB::bind_method(_MD("set_render_target_filter","enable"), &Viewport::set_render_target_filter);
- ObjectTypeDB::bind_method(_MD("get_render_target_filter"), &Viewport::get_render_target_filter);
+ ObjectTypeDB::bind_method(_MD("set_filter","enable"), &Viewport::set_filter);
+ ObjectTypeDB::bind_method(_MD("get_filter"), &Viewport::get_filter);
- ObjectTypeDB::bind_method(_MD("set_render_target_gen_mipmaps","enable"), &Viewport::set_render_target_gen_mipmaps);
- ObjectTypeDB::bind_method(_MD("get_render_target_gen_mipmaps"), &Viewport::get_render_target_gen_mipmaps);
+ ObjectTypeDB::bind_method(_MD("set_gen_mipmaps","enable"), &Viewport::set_gen_mipmaps);
+ ObjectTypeDB::bind_method(_MD("get_gen_mipmaps"), &Viewport::get_gen_mipmaps);
- ObjectTypeDB::bind_method(_MD("set_render_target_update_mode","mode"), &Viewport::set_render_target_update_mode);
- ObjectTypeDB::bind_method(_MD("get_render_target_update_mode"), &Viewport::get_render_target_update_mode);
+ ObjectTypeDB::bind_method(_MD("set_update_mode","mode"), &Viewport::set_update_mode);
+ ObjectTypeDB::bind_method(_MD("get_update_mode"), &Viewport::get_update_mode);
- ObjectTypeDB::bind_method(_MD("get_render_target_texture:RenderTargetTexture"), &Viewport::get_render_target_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:RenderTargetTexture"), &Viewport::get_texture);
ObjectTypeDB::bind_method(_MD("set_physics_object_picking","enable"), &Viewport::set_physics_object_picking);
ObjectTypeDB::bind_method(_MD("get_physics_object_picking"), &Viewport::get_physics_object_picking);
@@ -2671,7 +2679,7 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d);
ObjectTypeDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d);
- ObjectTypeDB::bind_method(_MD("set_render_target_to_screen_rect","rect"), &Viewport::set_render_target_to_screen_rect);
+ ObjectTypeDB::bind_method(_MD("set_attach_to_screen_rect","rect"), &Viewport::set_attach_to_screen_rect);
ObjectTypeDB::bind_method(_MD("get_mouse_pos"), &Viewport::get_mouse_pos);
ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"), &Viewport::warp_mouse);
@@ -2685,17 +2693,16 @@ void Viewport::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_gui_show_tooltip"), &Viewport::_gui_show_tooltip);
ObjectTypeDB::bind_method(_MD("_gui_remove_focus"), &Viewport::_gui_remove_focus);
- ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"), _SCS("set_rect"), _SCS("get_rect") );
+ ADD_PROPERTY( PropertyInfo(Variant::RECT2,"size"), _SCS("set_size"), _SCS("get_size") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"own_world"), _SCS("set_use_own_world"), _SCS("is_using_own_world") );
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world",PROPERTY_HINT_RESOURCE_TYPE,"World"), _SCS("set_world"), _SCS("get_world") );
// ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/v_flip"), _SCS("set_render_target_vflip"), _SCS("get_render_target_vflip") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/clear_on_new_frame"), _SCS("set_render_target_clear_on_new_frame"), _SCS("get_render_target_clear_on_new_frame") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/filter"), _SCS("set_render_target_filter"), _SCS("get_render_target_filter") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/gen_mipmaps"), _SCS("set_render_target_gen_mipmaps"), _SCS("get_render_target_gen_mipmaps") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/v_flip"), _SCS("set_vflip"), _SCS("get_vflip") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/clear_on_new_frame"), _SCS("set_clear_on_new_frame"), _SCS("get_clear_on_new_frame") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/filter"), _SCS("set_filter"), _SCS("get_filter") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/gen_mipmaps"), _SCS("set_gen_mipmaps"), _SCS("get_gen_mipmaps") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_update_mode"), _SCS("get_update_mode") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"physics/object_picking"), _SCS("set_physics_object_picking"), _SCS("get_physics_object_picking") );
@@ -2703,10 +2710,10 @@ void Viewport::_bind_methods() {
ADD_SIGNAL(MethodInfo("size_changed"));
- BIND_CONSTANT( RENDER_TARGET_UPDATE_DISABLED );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ONCE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_WHEN_VISIBLE );
- BIND_CONSTANT( RENDER_TARGET_UPDATE_ALWAYS );
+ BIND_CONSTANT( UPDATE_DISABLED );
+ BIND_CONSTANT( UPDATE_ONCE );
+ BIND_CONSTANT( UPDATE_WHEN_VISIBLE );
+ BIND_CONSTANT( UPDATE_ALWAYS );
}
@@ -2731,13 +2738,13 @@ Viewport::Viewport() {
size_override=false;
size_override_stretch=false;
size_override_size=Size2(1,1);
- render_target_gen_mipmaps=false;
- render_target=false;
- render_target_vflip=false;
- render_target_clear_on_new_frame=true;
- //render_target_clear=true;
- render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE;
- render_target_texture = Ref<RenderTargetTexture>( memnew( RenderTargetTexture(this) ) );
+ gen_mipmaps=false;
+
+ vflip=false;
+ clear_on_new_frame=true;
+ //clear=true;
+ update_mode=UPDATE_WHEN_VISIBLE;
+ texture = Ref<RenderTargetTexture>( memnew( RenderTargetTexture(this) ) );
physics_object_picking=false;
physics_object_capture=0;
@@ -2763,6 +2770,7 @@ Viewport::Viewport() {
gui.tooltip_label=NULL;
gui.drag_preview=NULL;
gui.drag_attempted=false;
+ gui.canvas_sort_index=0;
parent_control=NULL;
@@ -2776,8 +2784,8 @@ Viewport::~Viewport() {
VisualServer::get_singleton()->free( viewport );
SpatialSoundServer::get_singleton()->free(internal_listener);
SpatialSound2DServer::get_singleton()->free(internal_listener_2d);
- if (render_target_texture.is_valid())
- render_target_texture->vp=NULL; //so if used, will crash
+ if (texture.is_valid())
+ texture->vp=NULL; //so if used, will crash
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index f657f0507d..d610237bec 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -79,11 +79,11 @@ class Viewport : public Node {
OBJ_TYPE( Viewport, Node );
public:
- enum RenderTargetUpdateMode {
- RENDER_TARGET_UPDATE_DISABLED,
- RENDER_TARGET_UPDATE_ONCE, //then goes to disabled
- RENDER_TARGET_UPDATE_WHEN_VISIBLE, // default
- RENDER_TARGET_UPDATE_ALWAYS
+ enum UpdateMode {
+ UPDATE_DISABLED,
+ UPDATE_ONCE, //then goes to disabled
+ UPDATE_WHEN_VISIBLE, // default
+ UPDATE_ALWAYS
};
private:
@@ -114,7 +114,7 @@ friend class RenderTargetTexture;
Matrix32 global_canvas_transform;
Matrix32 stretch_transform;
- Rect2 rect;
+ Size2 size;
Rect2 to_screen_rect;
RID contact_2d_debug;
@@ -131,10 +131,10 @@ friend class RenderTargetTexture;
Rect2 last_vp_rect;
bool transparent_bg;
- bool render_target_vflip;
- bool render_target_clear_on_new_frame;
- bool render_target_filter;
- bool render_target_gen_mipmaps;
+ bool vflip;
+ bool clear_on_new_frame;
+ bool filter;
+ bool gen_mipmaps;
bool physics_object_picking;
List<InputEvent> physics_picking_events;
@@ -170,10 +170,10 @@ friend class RenderTargetTexture;
void _update_stretch_transform();
void _update_global_transform();
- bool render_target;
- RenderTargetUpdateMode render_target_update_mode;
- RID render_target_texture_rid;
- Ref<RenderTargetTexture> render_target_texture;
+
+ UpdateMode update_mode;
+ RID texture_rid;
+ Ref<RenderTargetTexture> texture;
struct GUI {
@@ -202,6 +202,7 @@ friend class RenderTargetTexture;
List<Control*> subwindows;
bool roots_order_dirty;
List<Control*> roots;
+ int canvas_sort_index; //for sorting items with canvas as root
GUI();
@@ -299,8 +300,10 @@ public:
void set_as_audio_listener_2d(bool p_enable);
bool is_audio_listener_2d() const;
- void set_rect(const Rect2& p_rect);
- Rect2 get_rect() const;
+ void set_size(const Size2& p_size);
+
+
+ Size2 get_size() const;
Rect2 get_visible_rect() const;
RID get_viewport() const;
@@ -327,29 +330,27 @@ public:
void set_size_override(bool p_enable,const Size2& p_size=Size2(-1,-1),const Vector2& p_margin=Vector2());
Size2 get_size_override() const;
+
bool is_size_override_enabled() const;
void set_size_override_stretch(bool p_enable);
bool is_size_override_stretch_enabled() const;
- void set_as_render_target(bool p_enable);
- bool is_set_as_render_target() const;
+ void set_vflip(bool p_enable);
+ bool get_vflip() const;
- void set_render_target_vflip(bool p_enable);
- bool get_render_target_vflip() const;
+ void set_clear_on_new_frame(bool p_enable);
+ bool get_clear_on_new_frame() const;
+ void clear();
- void set_render_target_clear_on_new_frame(bool p_enable);
- bool get_render_target_clear_on_new_frame() const;
- void render_target_clear();
+ void set_filter(bool p_enable);
+ bool get_filter() const;
- void set_render_target_filter(bool p_enable);
- bool get_render_target_filter() const;
+ void set_gen_mipmaps(bool p_enable);
+ bool get_gen_mipmaps() const;
- void set_render_target_gen_mipmaps(bool p_enable);
- bool get_render_target_gen_mipmaps() const;
-
- void set_render_target_update_mode(RenderTargetUpdateMode p_mode);
- RenderTargetUpdateMode get_render_target_update_mode() const;
- Ref<RenderTargetTexture> get_render_target_texture() const;
+ void set_update_mode(UpdateMode p_mode);
+ UpdateMode get_update_mode() const;
+ Ref<RenderTargetTexture> get_texture() const;
Vector2 get_camera_coords(const Vector2& p_viewport_coords) const;
@@ -367,8 +368,8 @@ public:
void set_disable_input(bool p_disable);
bool is_input_disabled() const;
- void set_render_target_to_screen_rect(const Rect2& p_rect);
- Rect2 get_render_target_to_screen_rect() const;
+ void set_attach_to_screen_rect(const Rect2& p_rect);
+ Rect2 get_attach_to_screen_rect() const;
Vector2 get_mouse_pos() const;
void warp_mouse(const Vector2& p_pos);
@@ -381,12 +382,17 @@ public:
Variant gui_get_drag_data() const;
Control *get_modal_stack_top() const;
+ void gui_reset_canvas_sort_index();
+ int gui_get_canvas_sort_index();
+
virtual String get_configuration_warning() const;
+
+
Viewport();
~Viewport();
};
-VARIANT_ENUM_CAST(Viewport::RenderTargetUpdateMode);
+VARIANT_ENUM_CAST(Viewport::UpdateMode);
#endif
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 104aeb2b5e..dcb2edf872 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -235,7 +235,6 @@ static ResourceFormatLoaderWAV *resource_loader_wav=NULL;
#endif
static ResourceFormatLoaderTheme *resource_loader_theme=NULL;
-static ResourceFormatLoaderShader *resource_loader_shader=NULL;
static ResourceFormatSaverText *resource_saver_text=NULL;
static ResourceFormatLoaderText *resource_loader_text=NULL;
@@ -269,8 +268,6 @@ void register_scene_types() {
resource_loader_theme = memnew( ResourceFormatLoaderTheme );
ResourceLoader::add_resource_format_loader( resource_loader_theme );
- resource_loader_shader = memnew( ResourceFormatLoaderShader );
- ResourceLoader::add_resource_format_loader( resource_loader_shader );
bool default_theme_hidpi=GLOBAL_DEF("display/use_hidpi_theme",false);
Globals::get_singleton()->set_custom_property_info("display/use_hidpi_theme",PropertyInfo(Variant::BOOL,"display/use_hidpi_theme",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT|PROPERTY_USAGE_RESTART_IF_CHANGED));
@@ -424,7 +421,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<SpotLight>();
ObjectTypeDB::register_type<AnimationTreePlayer>();
ObjectTypeDB::register_type<Portal>();
- ObjectTypeDB::register_type<Particles>();
+ //ObjectTypeDB::register_type<Particles>();
ObjectTypeDB::register_type<Position3D>();
ObjectTypeDB::register_type<Quad>();
ObjectTypeDB::register_type<NavigationMeshInstance>();
@@ -453,8 +450,8 @@ void register_scene_types() {
ObjectTypeDB::register_type<PathFollow>();
ObjectTypeDB::register_type<VisibilityNotifier>();
ObjectTypeDB::register_type<VisibilityEnabler>();
- ObjectTypeDB::register_type<BakedLightInstance>();
- ObjectTypeDB::register_type<BakedLightSampler>();
+ //ObjectTypeDB::register_type<BakedLightInstance>();
+ //ObjectTypeDB::register_type<BakedLightSampler>();
ObjectTypeDB::register_type<WorldEnvironment>();
ObjectTypeDB::register_type<RemoteTransform>();
@@ -489,7 +486,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<Particles2D>();
ObjectTypeDB::register_type<ParticleAttractor2D>();
ObjectTypeDB::register_type<Sprite>();
- ObjectTypeDB::register_type<ViewportSprite>();
+// ObjectTypeDB::register_type<ViewportSprite>();
ObjectTypeDB::register_type<SpriteFrames>();
ObjectTypeDB::register_type<AnimatedSprite>();
ObjectTypeDB::register_type<Position2D>();
@@ -538,17 +535,17 @@ void register_scene_types() {
/* REGISTER RESOURCES */
ObjectTypeDB::register_virtual_type<Shader>();
- ObjectTypeDB::register_virtual_type<ShaderGraph>();
+// ObjectTypeDB::register_virtual_type<ShaderGraph>();
ObjectTypeDB::register_type<CanvasItemShader>();
- ObjectTypeDB::register_type<CanvasItemShaderGraph>();
+// ObjectTypeDB::register_type<CanvasItemShaderGraph>();
#ifndef _3D_DISABLED
ObjectTypeDB::register_type<Mesh>();
ObjectTypeDB::register_virtual_type<Material>();
ObjectTypeDB::register_type<FixedMaterial>();
- ObjectTypeDB::register_type<ShaderMaterial>();
+// ObjectTypeDB::register_type<ShaderMaterial>();
ObjectTypeDB::register_type<RoomBounds>();
- ObjectTypeDB::register_type<MaterialShaderGraph>();
+// ObjectTypeDB::register_type<MaterialShaderGraph>();
ObjectTypeDB::register_type<MaterialShader>();
ObjectTypeDB::add_compatibility_type("Shader","MaterialShader");
ObjectTypeDB::add_compatibility_type("ParticleSystemMaterial","FixedMaterial");
@@ -568,7 +565,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<SurfaceTool>();
ObjectTypeDB::register_type<MeshDataTool>();
- ObjectTypeDB::register_type<BakedLight>();
+ //ObjectTypeDB::register_type<BakedLight>();
OS::get_singleton()->yield(); //may take time to init
@@ -590,8 +587,7 @@ void register_scene_types() {
ObjectTypeDB::register_type<StyleBoxEmpty>();
ObjectTypeDB::register_type<StyleBoxTexture>();
- ObjectTypeDB::register_type<StyleBoxFlat>();
- ObjectTypeDB::register_type<StyleBoxImageMask>();
+ ObjectTypeDB::register_type<StyleBoxFlat>();
ObjectTypeDB::register_type<Theme>();
ObjectTypeDB::add_compatibility_type("Font","BitmapFont");
@@ -664,7 +660,6 @@ void unregister_scene_types() {
memdelete( resource_loader_theme );
- memdelete( resource_loader_shader );
if (resource_saver_text) {
memdelete(resource_saver_text);
diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp
index e4510be874..38ed661cdd 100644
--- a/scene/resources/baked_light.cpp
+++ b/scene/resources/baked_light.cpp
@@ -29,6 +29,8 @@
#include "baked_light.h"
#include "servers/visual_server.h"
+#if 0
+
void BakedLight::set_mode(Mode p_mode) {
mode=p_mode;
@@ -582,7 +584,7 @@ BakedLight::BakedLight() {
tint=0.0;
ao_radius=2.5;
ao_strength=0.7;
- format=FORMAT_RGB;
+ format=FORMAT_RGB8;
transfer_only_uv2=false;
@@ -600,3 +602,4 @@ BakedLight::~BakedLight() {
VS::get_singleton()->free(baked_light);
}
+#endif
diff --git a/scene/resources/baked_light.h b/scene/resources/baked_light.h
index 16806d29e3..0eaa3df276 100644
--- a/scene/resources/baked_light.h
+++ b/scene/resources/baked_light.h
@@ -32,6 +32,7 @@
#include "resource.h"
#include "scene/resources/texture.h"
+#if 0
class BakedLight : public Resource {
OBJ_TYPE( BakedLight, Resource);
@@ -44,7 +45,7 @@ public:
enum Format {
- FORMAT_RGB,
+ FORMAT_RGB8,
FORMAT_HDR8,
FORMAT_HDR16
};
@@ -195,5 +196,5 @@ public:
VARIANT_ENUM_CAST(BakedLight::Format);
VARIANT_ENUM_CAST(BakedLight::Mode);
VARIANT_ENUM_CAST(BakedLight::BakeFlags);
-
+#endif
#endif // BAKED_LIGHT_H
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index f5bfce3ef8..57dc39138a 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -45,8 +45,8 @@ void BitMap::create_from_image_alpha(const Image& p_image){
ERR_FAIL_COND(p_image.empty());
Image img=p_image;
- img.convert(Image::FORMAT_INTENSITY);
- ERR_FAIL_COND(img.get_format()!=Image::FORMAT_INTENSITY);
+ img.convert(Image::FORMAT_LA8);
+ ERR_FAIL_COND(img.get_format()!=Image::FORMAT_LA8);
create(Size2(img.get_width(),img.get_height()));
@@ -58,7 +58,7 @@ void BitMap::create_from_image_alpha(const Image& p_image){
int bbyte = i/8;
int bbit = i % 8;
- if (r[i])
+ if (r[i*2])
w[bbyte]|=(1<<bbit);
}
@@ -193,7 +193,6 @@ void BitMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
-
}
BitMap::BitMap() {
diff --git a/scene/resources/default_theme/color_picker_hue.png b/scene/resources/default_theme/color_picker_hue.png
new file mode 100644
index 0000000000..9bdd24f4fe
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_hue.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_main.png b/scene/resources/default_theme/color_picker_main.png
new file mode 100644
index 0000000000..0498628180
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_main.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_sample.png b/scene/resources/default_theme/color_picker_sample.png
new file mode 100644
index 0000000000..b145a3e384
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_sample.png
Binary files differ
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 0740b591c4..266de77ca0 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -58,14 +58,14 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
@@ -108,14 +108,14 @@ static Ref<Texture> make_icon(T p_src) {
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
@@ -125,7 +125,7 @@ static Ref<Texture> make_icon(T p_src) {
static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,const char*lighting_code) {
Ref<Shader> shader = (memnew( Shader(Shader::MODE_CANVAS_ITEM) ));
- shader->set_code(vertex_code, fragment_code, lighting_code);
+// shader->set_code(vertex_code, fragment_code, lighting_code);
return shader;
}
@@ -214,6 +214,8 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_
return style;
}
+
+
void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref<Font> & large_font, Ref<Texture>& default_icon, Ref<StyleBox>& default_style, float p_scale) {
scale=p_scale;
@@ -832,10 +834,15 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) );
t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) );
+ t->set_icon("color_area", "ColorPicker", make_icon( color_picker_main_png));
+ t->set_icon("color_hue", "ColorPicker", make_icon( color_picker_hue_png));
+ t->set_icon("color_sample", "ColorPicker", make_icon( color_picker_sample_png));
t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, ""));
t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, ""));
+
+
// TooltipPanel
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);
@@ -962,7 +969,6 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon( "logo","Icons", make_icon(logo_png) );
-
// Theme
default_icon= make_icon(error_icon_png) ;
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 73c801483f..913ea9b5e9 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -69,6 +69,21 @@ static const unsigned char close_hl_png[]={
};
+static const unsigned char color_picker_hue_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0x35,0x30,0x61,0x19,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x24,0x18,0xa9,0xb3,0x2c,0xb7,0x0,0x0,0x0,0x23,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xc1,0x31,0x1,0x0,0x0,0x0,0xc2,0xa0,0xf5,0x4f,0x6d,0xd,0xf,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbe,0xd,0x31,0x0,0x0,0x1,0x35,0x84,0x14,0xe2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char color_picker_main_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0xd3,0x10,0x3f,0x31,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x23,0x22,0x20,0xfe,0x63,0xc2,0x0,0x0,0x0,0xd5,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0xc1,0x31,0x1,0x0,0x0,0x0,0xc2,0xa0,0xf5,0x4f,0xed,0x65,0xb,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x1b,0x1,0x2d,0x0,0x1,0x9e,0xcb,0xc2,0xed,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char color_picker_sample_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x14,0x8,0x2,0x0,0x0,0x0,0xed,0x20,0x74,0x8,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x27,0x37,0x29,0x4f,0x42,0x2d,0x0,0x0,0x0,0x61,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xd9,0xb1,0xd,0x0,0x21,0xc,0x3,0x40,0x40,0xbf,0x5f,0x66,0xcd,0x84,0xf9,0x96,0x19,0xf0,0x5d,0x87,0x5c,0x5b,0x9,0xca,0x9e,0x99,0x75,0xe9,0xee,0xfb,0x59,0x55,0x52,0xe9,0xc3,0xe9,0x59,0x10,0x4c,0x1,0x50,0x0,0x50,0x0,0x8,0xf4,0xf9,0x15,0x49,0x93,0x53,0x13,0x0,0x2b,0x10,0x28,0x0,0x28,0x0,0x64,0xd9,0x2e,0xc1,0xd2,0xe4,0xd4,0x4,0xc0,0xa,0x4,0xa,0x0,0xa,0x0,0x59,0x5c,0x82,0xa5,0xd1,0xa9,0x9,0x80,0x15,0x8,0x14,0x0,0x14,0x0,0xb2,0xfc,0x5b,0xb2,0x3c,0x5a,0x4,0xa1,0xf3,0x57,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
static const unsigned char dosfont_png[]={
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x80,0x1,0x0,0x0,0x0,0x0,0xeb,0x45,0x5c,0x66,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x1,0xdd,0x8a,0x13,0xa4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x89,0x0,0x0,0xb,0x89,0x1,0x37,0xc9,0xcb,0xad,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0x83,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0xd4,0xb1,0x6e,0xdb,0x30,0x10,0x0,0x50,0x22,0x3,0x27,0x22,0xc8,0x78,0x83,0x91,0xa9,0x1f,0xc0,0xa9,0x10,0xa,0x7e,0xc,0x11,0x14,0x87,0xc,0x1c,0x32,0x9,0x1a,0xe,0x46,0xa6,0xfc,0x43,0xff,0x86,0xb5,0x80,0x9b,0x88,0x8e,0x5d,0x64,0x18,0x9e,0xdc,0xd5,0x53,0x91,0xc1,0xa0,0x7a,0xa4,0xe4,0xd4,0x31,0xd2,0x25,0x70,0x97,0xa2,0x37,0x48,0xe6,0x33,0x45,0xdd,0x51,0x24,0x95,0x7a,0x23,0xe0,0x75,0x13,0xb,0xd8,0x93,0xbf,0x51,0x51,0xa3,0xac,0x99,0xc9,0x29,0x87,0x81,0x83,0xb2,0x0,0xc7,0xfe,0xee,0x43,0x58,0x85,0x95,0xb7,0xa6,0xb6,0xaf,0x7a,0xe9,0x93,0x63,0xc3,0xf2,0xc,0x96,0x3e,0xba,0x97,0x11,0x3,0xb5,0x46,0xc0,0x15,0x30,0x43,0x1,0xbd,0x6,0x81,0x71,0xa9,0xb2,0x82,0x9,0x92,0x3d,0xf6,0xb0,0xbd,0x5c,0xf2,0x53,0xf2,0x75,0xc,0x11,0x5f,0xc7,0xe0,0xc4,0xaa,0xb4,0x40,0x41,0xc4,0x69,0xd0,0x27,0x55,0x12,0x13,0x78,0x74,0xa7,0xb5,0xd8,0x3f,0x14,0x77,0x81,0x0,0x22,0x93,0x9b,0x4c,0x54,0x5b,0x72,0x6d,0x98,0x17,0xd1,0x33,0xb3,0x94,0xaa,0x3c,0x93,0xea,0xb4,0x76,0x31,0x6a,0x66,0x0,0xa9,0x59,0x1c,0x8c,0xe,0x33,0xc0,0x12,0x4c,0x29,0xc2,0xa5,0xc3,0xc1,0xd0,0xb2,0x64,0x6a,0x60,0xa3,0xc0,0xea,0xac,0x19,0x58,0x4b,0xa9,0x4a,0x17,0xf0,0xda,0x68,0xb6,0x5,0xec,0xb2,0xf6,0x88,0x33,0xc8,0x18,0x52,0xd5,0x5a,0x1,0xb3,0x61,0x1,0x53,0xdf,0x2,0x51,0x2d,0x33,0xdd,0x12,0x59,0xea,0x94,0x95,0x3c,0x80,0x2e,0x5e,0xf9,0xdb,0x71,0x73,0x70,0xcf,0x39,0x3b,0x76,0xb7,0xbb,0x7d,0xcf,0x74,0x50,0xd,0x62,0x40,0x44,0x6,0x83,0xfe,0xc7,0x8e,0x51,0x5,0x5c,0xe1,0xdd,0xdd,0xaa,0xc2,0xf8,0x53,0x80,0x31,0xe2,0xfd,0x7d,0x14,0x8,0x7e,0xcc,0x5,0x28,0x62,0xd7,0xc5,0xc,0xa6,0xf3,0xc3,0x46,0xa6,0x30,0xd7,0x1e,0x1b,0x2e,0xd0,0x7f,0x63,0x5f,0x1f,0xf1,0x32,0xc9,0x90,0x82,0xef,0xb9,0x82,0xc,0x5a,0x1,0xef,0x66,0x90,0xd7,0x7a,0x2c,0x80,0x13,0x94,0xc4,0xf6,0x9f,0xd8,0x75,0xbb,0x2c,0x89,0xed,0xff,0x42,0xe9,0xa7,0xfb,0xa4,0x84,0xec,0x13,0x45,0x7,0x1a,0xb9,0x97,0x18,0x65,0xab,0x4,0xf9,0x54,0x8c,0x3c,0x54,0xe8,0xed,0xa3,0x7c,0x7b,0x55,0xe0,0x8b,0x0,0xf6,0x4f,0x36,0xd6,0x3d,0xc3,0xe8,0x41,0xc0,0xa1,0xb1,0xdb,0x9,0xa8,0x29,0x0,0xe,0xec,0xc3,0x4,0xc1,0x8,0xc,0x0,0xd6,0x36,0xf3,0x23,0xba,0x80,0x3,0x6f,0x17,0x15,0xbe,0x4b,0xe5,0x8c,0x23,0xc2,0x57,0x7b,0x5d,0x61,0x53,0xc0,0x61,0xf,0xbd,0xd5,0x15,0x68,0x47,0x8e,0x0,0x7b,0x37,0xba,0xab,0xba,0x59,0xcc,0x79,0x3d,0xd7,0xaf,0x5a,0xe3,0x85,0x66,0x69,0xab,0x16,0x32,0x31,0x5b,0xd0,0xdb,0x66,0x2,0x2f,0x6f,0xe,0xb2,0x42,0xb5,0x87,0xdf,0xf0,0x59,0xae,0x6a,0x86,0xae,0x93,0x4c,0x7d,0x1b,0x9a,0x6b,0x84,0xdd,0x9a,0xd6,0xca,0xc8,0x89,0xc3,0xfb,0xd4,0x82,0xe,0x30,0xa2,0x2c,0x18,0xc2,0x98,0xb2,0x4f,0x8,0xba,0x83,0xa1,0x40,0x12,0x88,0x6f,0x43,0x38,0x82,0x1c,0x1f,0x15,0x70,0x82,0x96,0xa8,0xa5,0x3d,0xed,0x9c,0xde,0xb9,0x1,0xe9,0xb8,0x5f,0x4c,0x39,0xd2,0xa6,0xac,0xa6,0x48,0xe7,0xd0,0x95,0x53,0xb0,0xc4,0x7b,0x97,0xd4,0xcd,0x3c,0xdd,0xf0,0xd0,0x4e,0xbf,0xe6,0x65,0x24,0x5b,0x7b,0x7d,0xe,0xe5,0xd6,0xae,0xe9,0x90,0x64,0xfd,0x70,0x9e,0x21,0xb5,0x6c,0x5,0xa4,0xa2,0x87,0xe9,0xa3,0x25,0xf4,0x5,0x5c,0x39,0x61,0xa6,0x1e,0xbe,0x11,0x18,0x80,0xed,0xb,0x18,0x9b,0x70,0x70,0xec,0x5f,0x80,0x3f,0x26,0x27,0xb3,0xc9,0x33,0xc8,0x5c,0x2c,0x5a,0x59,0x1f,0xcb,0x2c,0x89,0x9d,0xae,0xf,0x7d,0xcc,0xdb,0x9c,0xdd,0xd5,0xed,0x7c,0x7f,0xbe,0xd0,0x52,0xf9,0x1f,0xff,0x76,0xfc,0x2,0x24,0x3a,0x65,0x42,0xf6,0x41,0x91,0x95,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 679c8a000c..83518e1f3e 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -573,7 +573,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 456e6a5ee7..d1efc0f705 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -321,7 +321,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 4551aff0ef..6fecdef59d 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -28,59 +28,7 @@
/*************************************************************************/
#include "environment.h"
#include "texture.h"
-void Environment::set_background(BG p_bg) {
- ERR_FAIL_INDEX(p_bg,BG_MAX);
- bg_mode=p_bg;
- VS::get_singleton()->environment_set_background(environment,VS::EnvironmentBG(p_bg));
-}
-
-Environment::BG Environment::get_background() const{
-
- return bg_mode;
-}
-
-void Environment::set_background_param(BGParam p_param, const Variant& p_value){
-
- ERR_FAIL_INDEX(p_param,BG_PARAM_MAX);
- bg_param[p_param]=p_value;
- VS::get_singleton()->environment_set_background_param(environment,VS::EnvironmentBGParam(p_param),p_value);
-
-}
-Variant Environment::get_background_param(BGParam p_param) const{
-
- ERR_FAIL_INDEX_V(p_param,BG_PARAM_MAX,Variant());
- return bg_param[p_param];
-
-}
-
-void Environment::set_enable_fx(Fx p_effect,bool p_enabled){
-
- ERR_FAIL_INDEX(p_effect,FX_MAX);
- fx_enabled[p_effect]=p_enabled;
- VS::get_singleton()->environment_set_enable_fx(environment,VS::EnvironmentFx(p_effect),p_enabled);
-
-}
-bool Environment::is_fx_enabled(Fx p_effect) const{
-
- ERR_FAIL_INDEX_V(p_effect,FX_MAX,false);
- return fx_enabled[p_effect];
-
-}
-
-void Environment::fx_set_param(FxParam p_param,const Variant& p_value){
-
- ERR_FAIL_INDEX(p_param,FX_PARAM_MAX);
- fx_param[p_param]=p_value;
- VS::get_singleton()->environment_fx_set_param(environment,VS::EnvironmentFxParam(p_param),p_value);
-
-}
-Variant Environment::fx_get_param(FxParam p_param) const{
-
- ERR_FAIL_INDEX_V(p_param,FX_PARAM_MAX,Variant());
- return fx_param[p_param];
-
-}
RID Environment::get_rid() const {
@@ -89,160 +37,6 @@ RID Environment::get_rid() const {
void Environment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_background","bgmode"),&Environment::set_background);
- ObjectTypeDB::bind_method(_MD("get_background"),&Environment::get_background);
-
- ObjectTypeDB::bind_method(_MD("set_background_param","param","value"),&Environment::set_background_param);
- ObjectTypeDB::bind_method(_MD("get_background_param","param"),&Environment::get_background_param);
-
- ObjectTypeDB::bind_method(_MD("set_enable_fx","effect","enabled"),&Environment::set_enable_fx);
- ObjectTypeDB::bind_method(_MD("is_fx_enabled","effect"),&Environment::is_fx_enabled);
-
- ObjectTypeDB::bind_method(_MD("fx_set_param","param","value"),&Environment::fx_set_param);
- ObjectTypeDB::bind_method(_MD("fx_get_param","param"),&Environment::fx_get_param);
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"ambient_light/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_AMBIENT_LIGHT);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"ambient_light/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_ENERGY);
-
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fxaa/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FXAA);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Canvas"),_SCS("set_background"),_SCS("get_background"));
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_TEXTURE);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"CubeMap"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"background/canvas_max_layer"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_scale",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_strength",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,SoftLight"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom_treshold",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"dof_blur/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_DOF_BLUR);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"dof_blur/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/begin",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/range",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_RANGE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"hdr/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_HDR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/tonemapper",PROPERTY_HINT_ENUM,"Linear,Log,Reinhardt,ReinhardtAutoWhite"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_TONEMAPPER);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/white",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_WHITE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_treshold",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_scale",PROPERTY_HINT_RANGE,"0.00,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/min_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MIN_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/max_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MAX_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure_adj_speed",PROPERTY_HINT_RANGE,"0.001,64,0.001"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FOG);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/begin",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/begin_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/end_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_END_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/bg"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BG);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"bcs/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_BCS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_BRIGHTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_CONTRAST);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_SATURATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"srgb/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_SRGB);
-
-
-
-
-
-/*
- FX_PARAM_BLOOM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_BLOOM_GLOW_BLUR_PASSES,
- FX_PARAM_BLOOM_AMOUNT=VS::ENV_FX_PARAM_BLOOM_AMOUNT,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
- FX_PARAM_DOF_BLUR_END=VS::ENV_FX_PARAM_DOF_BLUR_END,
- FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
- FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
- FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
- FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
- FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_GAMMA_VALUE=VS::ENV_FX_PARAM_GAMMA_VALUE,
- FX_PARAM_BRIGHTNESS_VALUE=VS::ENV_FX_PARAM_BRIGHTNESS_VALUE,
- FX_PARAM_CONTRAST_VALUE=VS::ENV_FX_PARAM_CONTRAST_VALUE,
- FX_PARAM_SATURATION_VALUE=VS::ENV_FX_PARAM_SATURATION_VALUE,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
-*/
-
- BIND_CONSTANT( BG_KEEP );
- BIND_CONSTANT( BG_DEFAULT_COLOR );
- BIND_CONSTANT( BG_COLOR );
- BIND_CONSTANT( BG_TEXTURE );
- BIND_CONSTANT( BG_CUBEMAP );
- BIND_CONSTANT( BG_CANVAS );
- BIND_CONSTANT( BG_MAX );
-
- BIND_CONSTANT( BG_PARAM_CANVAS_MAX_LAYER );
- BIND_CONSTANT( BG_PARAM_COLOR );
- BIND_CONSTANT( BG_PARAM_TEXTURE );
- BIND_CONSTANT( BG_PARAM_CUBEMAP );
- BIND_CONSTANT( BG_PARAM_ENERGY );
- BIND_CONSTANT( BG_PARAM_GLOW );
- BIND_CONSTANT( BG_PARAM_MAX );
-
-
- BIND_CONSTANT( FX_AMBIENT_LIGHT );
- BIND_CONSTANT( FX_FXAA );
- BIND_CONSTANT( FX_GLOW );
- BIND_CONSTANT( FX_DOF_BLUR );
- BIND_CONSTANT( FX_HDR );
- BIND_CONSTANT( FX_FOG );
- BIND_CONSTANT( FX_BCS);
- BIND_CONSTANT( FX_SRGB );
- BIND_CONSTANT( FX_MAX );
-
-
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_ADDITIVE );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SCREEN );
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_SOFTLIGHT );
-
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LINEAR );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_LOG );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT );
- BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE );
-
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_COLOR );
- BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_ENERGY );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_SCALE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_STRENGTH );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_BLEND_MODE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM);
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM_TRESHOLD);
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_PASSES );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_BEGIN );
- BIND_CONSTANT( FX_PARAM_DOF_BLUR_RANGE );
- BIND_CONSTANT( FX_PARAM_HDR_TONEMAPPER);
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE );
- BIND_CONSTANT( FX_PARAM_HDR_WHITE );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_TRESHOLD );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_SCALE );
- BIND_CONSTANT( FX_PARAM_HDR_MIN_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_MAX_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN );
- BIND_CONSTANT( FX_PARAM_FOG_ATTENUATION );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_END_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_BG );
- BIND_CONSTANT( FX_PARAM_BCS_BRIGHTNESS );
- BIND_CONSTANT( FX_PARAM_BCS_CONTRAST );
- BIND_CONSTANT( FX_PARAM_BCS_SATURATION );
- BIND_CONSTANT( FX_PARAM_MAX );
}
@@ -250,45 +44,8 @@ Environment::Environment() {
environment = VS::get_singleton()->environment_create();
- set_background(BG_DEFAULT_COLOR);
- set_background_param(BG_PARAM_COLOR,Color(0,0,0));
- set_background_param(BG_PARAM_TEXTURE,Ref<ImageTexture>());
- set_background_param(BG_PARAM_CUBEMAP,Ref<CubeMap>());
- set_background_param(BG_PARAM_ENERGY,1.0);
- set_background_param(BG_PARAM_SCALE,1.0);
- set_background_param(BG_PARAM_GLOW,0.0);
-
- for(int i=0;i<FX_MAX;i++)
- set_enable_fx(Fx(i),false);
-
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_AMBIENT_LIGHT_ENERGY,1.0);
- fx_set_param(FX_PARAM_GLOW_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_SCALE,1);
- fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH,1);
- fx_set_param(FX_PARAM_GLOW_BLOOM,0.0);
- fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD,0.5);
- fx_set_param(FX_PARAM_DOF_BLUR_PASSES,1);
- fx_set_param(FX_PARAM_DOF_BLUR_BEGIN,100.0);
- fx_set_param(FX_PARAM_DOF_BLUR_RANGE,10.0);
- fx_set_param(FX_PARAM_HDR_TONEMAPPER,FX_HDR_TONE_MAPPER_LINEAR);
- fx_set_param(FX_PARAM_HDR_EXPOSURE,0.4);
- fx_set_param(FX_PARAM_HDR_WHITE,1.0);
- fx_set_param(FX_PARAM_HDR_GLOW_TRESHOLD,0.95);
- fx_set_param(FX_PARAM_HDR_GLOW_SCALE,0.2);
- fx_set_param(FX_PARAM_HDR_MIN_LUMINANCE,0.4);
- fx_set_param(FX_PARAM_HDR_MAX_LUMINANCE,8.0);
- fx_set_param(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,0.5);
- fx_set_param(FX_PARAM_FOG_BEGIN,100.0);
- fx_set_param(FX_PARAM_FOG_ATTENUATION,1.0);
- fx_set_param(FX_PARAM_FOG_BEGIN_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_END_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_BG,true);
- fx_set_param(FX_PARAM_BCS_BRIGHTNESS,1.0);
- fx_set_param(FX_PARAM_BCS_CONTRAST,1.0);
- fx_set_param(FX_PARAM_BCS_SATURATION,1.0);
-
}
+
Environment::~Environment() {
VS::get_singleton()->free(environment);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index a72cc6a47f..f8ea0cb36f 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -37,107 +37,16 @@ class Environment : public Resource {
OBJ_TYPE(Environment,Resource);
public:
- enum BG {
- BG_KEEP=VS::ENV_BG_KEEP,
- BG_DEFAULT_COLOR=VS::ENV_BG_DEFAULT_COLOR,
- BG_COLOR=VS::ENV_BG_COLOR,
- BG_TEXTURE=VS::ENV_BG_TEXTURE,
- BG_CUBEMAP=VS::ENV_BG_CUBEMAP,
- BG_CANVAS=VS::ENV_BG_CANVAS,
- BG_MAX=VS::ENV_BG_MAX
- };
-
- enum BGParam {
-
- BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
- BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
- BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE,
- BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
- BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
- BG_PARAM_SCALE=VS::ENV_BG_PARAM_SCALE,
- BG_PARAM_GLOW=VS::ENV_BG_PARAM_GLOW,
- BG_PARAM_MAX=VS::ENV_BG_PARAM_MAX
- };
-
- enum Fx {
- FX_AMBIENT_LIGHT=VS::ENV_FX_AMBIENT_LIGHT,
- FX_FXAA=VS::ENV_FX_FXAA,
- FX_GLOW=VS::ENV_FX_GLOW,
- FX_DOF_BLUR=VS::ENV_FX_DOF_BLUR,
- FX_HDR=VS::ENV_FX_HDR,
- FX_FOG=VS::ENV_FX_FOG,
- FX_BCS=VS::ENV_FX_BCS,
- FX_SRGB=VS::ENV_FX_SRGB,
- FX_MAX=VS::ENV_FX_MAX,
- };
-
- enum FxBlurBlendMode {
- FX_BLUR_BLEND_MODE_ADDITIVE,
- FX_BLUR_BLEND_MODE_SCREEN,
- FX_BLUR_BLEND_MODE_SOFTLIGHT,
- };
-
- enum FxHDRToneMapper {
- FX_HDR_TONE_MAPPER_LINEAR,
- FX_HDR_TONE_MAPPER_LOG,
- FX_HDR_TONE_MAPPER_REINHARDT,
- FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE,
- };
-
- enum FxParam {
- FX_PARAM_AMBIENT_LIGHT_COLOR=VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
- FX_PARAM_AMBIENT_LIGHT_ENERGY=VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
- FX_PARAM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
- FX_PARAM_GLOW_BLUR_SCALE=VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
- FX_PARAM_GLOW_BLUR_STRENGTH=VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
- FX_PARAM_GLOW_BLUR_BLEND_MODE=VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
- FX_PARAM_GLOW_BLOOM=VS::ENV_FX_PARAM_GLOW_BLOOM,
- FX_PARAM_GLOW_BLOOM_TRESHOLD=VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
- FX_PARAM_DOF_BLUR_RANGE=VS::ENV_FX_PARAM_DOF_BLUR_RANGE,
- FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
- FX_PARAM_HDR_TONEMAPPER=VS::ENV_FX_PARAM_HDR_TONEMAPPER,
- FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
- FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
- FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
- FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_BCS_BRIGHTNESS=VS::ENV_FX_PARAM_BCS_BRIGHTNESS,
- FX_PARAM_BCS_CONTRAST=VS::ENV_FX_PARAM_BCS_CONTRAST,
- FX_PARAM_BCS_SATURATION=VS::ENV_FX_PARAM_BCS_SATURATION,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
- };
private:
- BG bg_mode;
- Variant bg_param[BG_PARAM_MAX];
- bool fx_enabled[FX_MAX];
- Variant fx_param[FX_PARAM_MAX];
+
RID environment;
protected:
static void _bind_methods();
public:
- void set_background(BG p_bg);
- BG get_background() const;
-
- void set_background_param(BGParam p_param, const Variant& p_value);
- Variant get_background_param(BGParam p_param) const;
-
- void set_enable_fx(Fx p_effect,bool p_enabled);
- bool is_fx_enabled(Fx p_effect) const;
-
- void fx_set_param(FxParam p_param,const Variant& p_value);
- Variant fx_get_param(FxParam p_param) const;
virtual RID get_rid() const;
@@ -145,9 +54,5 @@ public:
~Environment();
};
-VARIANT_ENUM_CAST( Environment::BG );
-VARIANT_ENUM_CAST( Environment::BGParam );
-VARIANT_ENUM_CAST( Environment::Fx );
-VARIANT_ENUM_CAST( Environment::FxParam );
#endif // ENVIRONMENT_H
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 9dc54ef0e4..3ebe5b7800 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -29,144 +29,14 @@
#include "material.h"
#include "scene/scene_string_names.h"
-
-static const char*_flag_names[Material::FLAG_MAX]={
- "visible",
- "double_sided",
- "invert_faces",
- "unshaded",
- "on_top",
- "lightmap_on_uv2",
- "colarray_is_srgb"
-};
-
-
-static const Material::Flag _flag_indices[Material::FLAG_MAX]={
- Material::FLAG_VISIBLE,
- Material::FLAG_DOUBLE_SIDED,
- Material::FLAG_INVERT_FACES,
- Material::FLAG_UNSHADED,
- Material::FLAG_ONTOP,
- Material::FLAG_LIGHTMAP_ON_UV2,
- Material::FLAG_COLOR_ARRAY_SRGB,
-};
-
-
RID Material::get_rid() const {
return material;
}
-void Material::set_flag(Flag p_flag,bool p_enabled) {
-
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_enabled;
- VisualServer::get_singleton()->material_set_flag(material,(VS::MaterialFlag)p_flag,p_enabled);
- _change_notify();
-}
-
-
-void Material::set_blend_mode(BlendMode p_blend_mode) {
-
- ERR_FAIL_INDEX(p_blend_mode,4);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->material_set_blend_mode(material,(VS::MaterialBlendMode)p_blend_mode);
- _change_notify();
-}
-
-Material::BlendMode Material::get_blend_mode() const {
-
- return blend_mode;
-}
-
-
-void Material::set_depth_draw_mode(DepthDrawMode p_depth_draw_mode) {
-
- depth_draw_mode=p_depth_draw_mode;
- VisualServer::get_singleton()->material_set_depth_draw_mode(material,(VS::MaterialDepthDrawMode)p_depth_draw_mode);
-}
-
-Material::DepthDrawMode Material::get_depth_draw_mode() const {
-
- return depth_draw_mode;
-}
-
-bool Material::get_flag(Flag p_flag) const {
-
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
- return flags[p_flag];
-}
-
-void Material::set_line_width(float p_width) {
-
- line_width=p_width;
- VisualServer::get_singleton()->material_set_line_width(material,p_width);
- _change_notify("line_width");
-}
-
-float Material::get_line_width() const {
-
- return line_width;
-}
-
-
-void Material::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_flag","flag","enable"),&Material::set_flag);
- ObjectTypeDB::bind_method(_MD("get_flag","flag"),&Material::get_flag);
- ObjectTypeDB::bind_method(_MD("set_blend_mode","mode"),&Material::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&Material::get_blend_mode);
- ObjectTypeDB::bind_method(_MD("set_line_width","width"),&Material::set_line_width);
- ObjectTypeDB::bind_method(_MD("get_line_width"),&Material::get_line_width);
- ObjectTypeDB::bind_method(_MD("set_depth_draw_mode","mode"),&Material::set_depth_draw_mode);
- ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"),&Material::get_depth_draw_mode);
-
-
- for(int i=0;i<FLAG_MAX;i++)
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"flags/"+_flag_names[i] ),_SCS("set_flag"),_SCS("get_flag"),_flag_indices[i]);
-
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,PMAlpha" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/depth_draw",PROPERTY_HINT_ENUM,"Always,Opaque Only,Pre-Pass Alpha,Never" ), _SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/line_width",PROPERTY_HINT_RANGE,"0.1,32.0,0.1" ), _SCS("set_line_width"),_SCS("get_line_width"));
-
- BIND_CONSTANT( FLAG_VISIBLE );
- BIND_CONSTANT( FLAG_DOUBLE_SIDED );
- BIND_CONSTANT( FLAG_INVERT_FACES );
- BIND_CONSTANT( FLAG_UNSHADED );
- BIND_CONSTANT( FLAG_ONTOP );
- BIND_CONSTANT( FLAG_LIGHTMAP_ON_UV2 );
- BIND_CONSTANT( FLAG_COLOR_ARRAY_SRGB );
- BIND_CONSTANT( FLAG_MAX );
-
- BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA );
- BIND_CONSTANT( DEPTH_DRAW_NEVER );
-
- BIND_CONSTANT( BLEND_MODE_MIX );
- BIND_CONSTANT( BLEND_MODE_ADD );
- BIND_CONSTANT( BLEND_MODE_SUB );
- BIND_CONSTANT( BLEND_MODE_MUL );
- BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );
-
-}
-
-Material::Material(const RID& p_material) {
-
- material=p_material;
-
- flags[FLAG_VISIBLE]=true;
- flags[FLAG_DOUBLE_SIDED]=false;
- flags[FLAG_INVERT_FACES]=false;
- flags[FLAG_UNSHADED]=false;
- flags[FLAG_ONTOP]=false;
- flags[FLAG_LIGHTMAP_ON_UV2]=true;
- flags[FLAG_COLOR_ARRAY_SRGB]=false;
-
- depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
-
- blend_mode=BLEND_MODE_MIX;
+Material::Material() {
+ material=VisualServer::get_singleton()->material_create();
}
Material::~Material() {
@@ -174,431 +44,15 @@ Material::~Material() {
VisualServer::get_singleton()->free(material);
}
-static const char*_param_names[FixedMaterial::PARAM_MAX]={
- "diffuse",
- "detail",
- "specular",
- "emission",
- "specular_exp",
- "glow",
- "normal",
- "shade_param"
-};
-
-static const char*_full_param_names[FixedMaterial::PARAM_MAX]={
- "params/diffuse",
- "params/detail",
- "params/specular",
- "params/emission",
- "params/specular_exp",
- "params/glow",
- "params/normal",
- "params/shade_param"
-};
-
-/*
-static const char*_texture_param_names[FixedMaterial::PARAM_MAX]={
- "tex_diffuse",
- "tex_detail",
- "tex_specular",
- "tex_emission",
- "tex_specular_exp",
- "tex_glow",
- "tex_detail_mix",
- "tex_normal",
- "tex_shade_param"
-};
-*/
-static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX]={
- FixedMaterial::PARAM_DIFFUSE,
- FixedMaterial::PARAM_DETAIL,
- FixedMaterial::PARAM_SPECULAR,
- FixedMaterial::PARAM_EMISSION,
- FixedMaterial::PARAM_SPECULAR_EXP,
- FixedMaterial::PARAM_GLOW,
- FixedMaterial::PARAM_NORMAL,
- FixedMaterial::PARAM_SHADE_PARAM,
-};
-
-
-
-
-void FixedMaterial::set_parameter(Parameter p_parameter, const Variant& p_value) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- if ((p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION)) {
-
- if (p_value.get_type()!=Variant::COLOR) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects Color");
- ERR_FAIL();
- }
- } else {
-
- if (!p_value.is_num()) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects scalar");
- ERR_FAIL();
- }
- }
-
- ERR_FAIL_COND( (p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION) && p_value.get_type()!=Variant::COLOR );
- ERR_FAIL_COND( p_parameter!=PARAM_SHADE_PARAM && p_parameter!=PARAM_DIFFUSE && p_parameter!=PARAM_DETAIL && p_parameter!=PARAM_SPECULAR && p_parameter!=PARAM_EMISSION && p_value.get_type()!=Variant::REAL && p_value.get_type()!=Variant::INT );
-
- param[p_parameter]=p_value;
-
- VisualServer::get_singleton()->fixed_material_set_param(material,(VS::FixedMaterialParam)p_parameter,p_value);
-
- _change_notify(_full_param_names[p_parameter]);
-}
-
-Variant FixedMaterial::get_parameter(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Variant());
- return param[p_parameter];
-}
-
-
-
-void FixedMaterial::set_texture(Parameter p_parameter, Ref<Texture> p_texture) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
-
- texture_param[p_parameter]=p_texture;
- VisualServer::get_singleton()->fixed_material_set_texture(material,(VS::FixedMaterialParam)p_parameter,p_texture.is_null()?RID():p_texture->get_rid());
-
- _change_notify();
-}
-Ref<Texture> FixedMaterial::get_texture(Parameter p_parameter) const {
-
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Ref<Texture>());
- return texture_param[p_parameter];
-}
-
-void FixedMaterial::set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- ERR_FAIL_INDEX(p_mode,4);
-
- if (p_mode==texture_texcoord[p_parameter])
- return;
-
- texture_texcoord[p_parameter]=p_mode;
-
- VisualServer::get_singleton()->fixed_material_set_texcoord_mode(material,(VS::FixedMaterialParam)p_parameter,(VS::FixedMaterialTexCoordMode)p_mode);
-
- _change_notify();
-}
-
-FixedMaterial::TexCoordMode FixedMaterial::get_texcoord_mode(Parameter p_parameter) const {
-
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,TEXCOORD_UV);
- return texture_texcoord[p_parameter];
-}
-
-void FixedMaterial::set_light_shader(LightShader p_shader) {
-
- light_shader=p_shader;
- VS::get_singleton()->fixed_material_set_light_shader(material,VS::FixedMaterialLightShader(p_shader));
-}
-
-FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
-
- return light_shader;
-}
-
-
-void FixedMaterial::set_uv_transform(const Transform& p_transform) {
-
- uv_transform=p_transform;
- VisualServer::get_singleton()->fixed_material_set_uv_transform(material, p_transform );
- _change_notify();
-}
-
-Transform FixedMaterial::get_uv_transform() const {
-
- return uv_transform;
-}
-
-
-
-
-
-void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,5);
- fixed_flags[p_flag]=p_value;
- VisualServer::get_singleton()->fixed_material_set_flag(material,(VS::FixedMaterialFlags)p_flag,p_value);
-
-}
-
-bool FixedMaterial::get_fixed_flag(FixedFlag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,5,false);
- return fixed_flags[p_flag];
-}
-
-void FixedMaterial::set_point_size(float p_size) {
-
- ERR_FAIL_COND(p_size<0);
- point_size=p_size;
- VisualServer::get_singleton()->fixed_material_set_point_size(material,p_size);
-}
-
-float FixedMaterial::get_point_size() const{
-
-
- return point_size;
-}
-
-
-void FixedMaterial::_bind_methods() {
-
-
- ObjectTypeDB::bind_method(_MD("set_parameter","param","value"),&FixedMaterial::set_parameter);
- ObjectTypeDB::bind_method(_MD("get_parameter","param"),&FixedMaterial::get_parameter);
-
- ObjectTypeDB::bind_method(_MD("set_texture","param","texture:Texture"),&FixedMaterial::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","param"),&FixedMaterial::get_texture);
+FixedMaterial::FixedMaterial() {
- ObjectTypeDB::bind_method(_MD("set_texcoord_mode","param","mode"),&FixedMaterial::set_texcoord_mode);
- ObjectTypeDB::bind_method(_MD("get_texcoord_mode","param"),&FixedMaterial::get_texcoord_mode);
-
- ObjectTypeDB::bind_method(_MD("set_fixed_flag","flag","value"),&FixedMaterial::set_fixed_flag);
- ObjectTypeDB::bind_method(_MD("get_fixed_flag","flag"),&FixedMaterial::get_fixed_flag);
-
- ObjectTypeDB::bind_method(_MD("set_uv_transform","transform"),&FixedMaterial::set_uv_transform);
- ObjectTypeDB::bind_method(_MD("get_uv_transform"),&FixedMaterial::get_uv_transform);
-
- ObjectTypeDB::bind_method(_MD("set_light_shader","shader"),&FixedMaterial::set_light_shader);
- ObjectTypeDB::bind_method(_MD("get_light_shader"),&FixedMaterial::get_light_shader);
-
- ObjectTypeDB::bind_method(_MD("set_point_size","size"),&FixedMaterial::set_point_size);
- ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedMaterial::get_point_size);
-
-
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_color_array" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_point_size" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/discard_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_xy_normalmap" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_XY_NORMALMAP);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/diffuse" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR );
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/specular_exp", PROPERTY_HINT_RANGE,"1,64,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR_EXP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/detail_mix", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DETAIL );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/normal_depth", PROPERTY_HINT_RANGE,"-4,4,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_NORMAL );
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/shader", PROPERTY_HINT_ENUM,"Lambert,Wrap,Velvet,Toon" ), _SCS("set_light_shader"), _SCS("get_light_shader") );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/shader_param", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/glow", PROPERTY_HINT_RANGE,"0,8,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_GLOW );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/point_size", PROPERTY_HINT_RANGE,"0,1024,1" ), _SCS("set_point_size"), _SCS("get_point_size"));
- ADD_PROPERTY( PropertyInfo( Variant::TRANSFORM, "uv_xform"), _SCS("set_uv_transform"), _SCS("get_uv_transform") );
-
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI( PropertyInfo( Variant::OBJECT, String()+"textures/"+_param_names[i],PROPERTY_HINT_RESOURCE_TYPE,"Texture" ), _SCS("set_texture"), _SCS("get_texture"), _param_indices[i]);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, String()+"textures/"+_param_names[i]+"_tc",PROPERTY_HINT_ENUM,"UV,UV Xform,UV2,Sphere" ), _SCS("set_texcoord_mode"), _SCS("get_texcoord_mode"), _param_indices[i] );
- }
-
-
- BIND_CONSTANT( PARAM_DIFFUSE );
- BIND_CONSTANT( PARAM_DETAIL );
- BIND_CONSTANT( PARAM_SPECULAR );
- BIND_CONSTANT( PARAM_EMISSION );
- BIND_CONSTANT( PARAM_SPECULAR_EXP );
- BIND_CONSTANT( PARAM_GLOW );
- BIND_CONSTANT( PARAM_NORMAL );
- BIND_CONSTANT( PARAM_SHADE_PARAM );
- BIND_CONSTANT( PARAM_MAX );
-
- BIND_CONSTANT( TEXCOORD_UV );
- BIND_CONSTANT( TEXCOORD_UV_TRANSFORM );
- BIND_CONSTANT( TEXCOORD_UV2 );
- BIND_CONSTANT( TEXCOORD_SPHERE );
-
- BIND_CONSTANT( FLAG_USE_ALPHA );
- BIND_CONSTANT( FLAG_USE_COLOR_ARRAY );
- BIND_CONSTANT( FLAG_USE_POINT_SIZE );
- BIND_CONSTANT( FLAG_DISCARD_ALPHA );
-
- BIND_CONSTANT( LIGHT_SHADER_LAMBERT );
- BIND_CONSTANT( LIGHT_SHADER_WRAP );
- BIND_CONSTANT( LIGHT_SHADER_VELVET );
- BIND_CONSTANT( LIGHT_SHADER_TOON );
}
-
-FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_create()) {
-
-
-
- param[PARAM_DIFFUSE]=Color(1,1,1);
- param[PARAM_SPECULAR]=Color(0.0,0.0,0.0);
- param[PARAM_EMISSION]=Color(0.0,0.0,0.0);
- param[PARAM_SPECULAR_EXP]=40;
- param[PARAM_GLOW]=0;
- param[PARAM_NORMAL]=1;
- param[PARAM_SHADE_PARAM]=0.5;
- param[PARAM_DETAIL]=1.0;
-
- set_flag(FLAG_COLOR_ARRAY_SRGB,true);
-
- fixed_flags[FLAG_USE_ALPHA]=false;
- fixed_flags[FLAG_USE_COLOR_ARRAY]=false;
- fixed_flags[FLAG_USE_POINT_SIZE]=false;
- fixed_flags[FLAG_USE_XY_NORMALMAP]=false;
- fixed_flags[FLAG_DISCARD_ALPHA]=false;
-
-
- for(int i=0;i<PARAM_MAX;i++) {
-
- texture_texcoord[i]=TEXCOORD_UV;
- }
-
- light_shader=LIGHT_SHADER_LAMBERT;
-
- point_size=1.0;
-}
-
-
FixedMaterial::~FixedMaterial() {
-}
-
-
-
-
-bool ShaderMaterial::_set(const StringName& p_name, const Variant& p_value) {
-
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
- set_shader(p_value);
- return true;
- } else {
-
- if (shader.is_valid()) {
-
-
- StringName pr = shader->remap_param(p_name);
- if (!pr) {
- String n = p_name;
- if (n.find("param/")==0) { //backwards compatibility
- pr = n.substr(6,n.length());
- }
- }
- if (pr) {
- VisualServer::get_singleton()->material_set_param(material,pr,p_value);
- return true;
- }
- }
- }
-
- return false;
-}
-
-bool ShaderMaterial::_get(const StringName& p_name,Variant &r_ret) const {
-
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
-
- r_ret=get_shader();
- return true;
- } else {
-
- if (shader.is_valid()) {
-
- StringName pr = shader->remap_param(p_name);
- if (pr) {
- r_ret=VisualServer::get_singleton()->material_get_param(material,pr);
- return true;
- }
- }
-
- }
-
-
- return false;
-}
-
-
-void ShaderMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
-
- p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"MaterialShader,MaterialShaderGraph" ) );
-
- if (!shader.is_null()) {
-
- shader->get_param_list(p_list);
- }
-
-}
-
-
-void ShaderMaterial::_shader_changed() {
-
- _change_notify(); //also all may have changed then
-}
-
-void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) {
-
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL);
-
- if (shader.is_valid())
- shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- shader=p_shader;
- VS::get_singleton()->material_set_shader(material,shader.is_valid()?shader->get_rid():RID());
- if (shader.is_valid()) {
- shader->connect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- }
- _change_notify();
-
-}
-
-Ref<Shader> ShaderMaterial::get_shader() const {
-
- return shader;
}
-
-void ShaderMaterial::set_shader_param(const StringName& p_param,const Variant& p_value) {
-
- VisualServer::get_singleton()->material_set_param(material,p_param,p_value);
-
-}
-
-Variant ShaderMaterial::get_shader_param(const StringName& p_param) const{
-
- return VisualServer::get_singleton()->material_get_param(material,p_param);
-}
-
-
-
-void ShaderMaterial::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"), &ShaderMaterial::set_shader );
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &ShaderMaterial::get_shader );
-
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value:Variant"), &ShaderMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param:Variant","param"), &ShaderMaterial::get_shader_param);
-
- ObjectTypeDB::bind_method(_MD("_shader_changed"), &ShaderMaterial::_shader_changed );
-}
-
-
-void ShaderMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
-
- String f = p_function.operator String();
- if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
-
- if (shader.is_valid()) {
- List<PropertyInfo> pl;
- shader->get_param_list(&pl);
- for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
- }
- }
- }
- Material::get_argument_options(p_function,p_idx,r_options);
-}
-
-ShaderMaterial::ShaderMaterial() :Material(VisualServer::get_singleton()->material_create()){
-
-
-}
-
-
/////////////////////////////////
diff --git a/scene/resources/material.h b/scene/resources/material.h
index dbd05c466f..87afa60ce9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -45,209 +45,27 @@ class Material : public Resource {
RES_BASE_EXTENSION("mtl");
OBJ_SAVE_TYPE( Material );
-public:
-
- enum Flag {
- FLAG_VISIBLE = VS::MATERIAL_FLAG_VISIBLE,
- FLAG_DOUBLE_SIDED = VS::MATERIAL_FLAG_DOUBLE_SIDED,
- FLAG_INVERT_FACES = VS::MATERIAL_FLAG_INVERT_FACES,
- FLAG_UNSHADED = VS::MATERIAL_FLAG_UNSHADED,
- FLAG_ONTOP = VS::MATERIAL_FLAG_ONTOP,
- FLAG_LIGHTMAP_ON_UV2 = VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2,
- FLAG_COLOR_ARRAY_SRGB = VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB,
- FLAG_MAX = VS::MATERIAL_FLAG_MAX
- };
-
- enum BlendMode {
- BLEND_MODE_MIX = VS::MATERIAL_BLEND_MODE_MIX,
- BLEND_MODE_MUL = VS::MATERIAL_BLEND_MODE_MUL,
- BLEND_MODE_ADD = VS::MATERIAL_BLEND_MODE_ADD,
- BLEND_MODE_SUB = VS::MATERIAL_BLEND_MODE_SUB,
- BLEND_MODE_PREMULT_ALPHA = VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA,
-
- };
-
- enum DepthDrawMode {
- DEPTH_DRAW_ALWAYS = VS::MATERIAL_DEPTH_DRAW_ALWAYS,
- DEPTH_DRAW_OPAQUE_ONLY = VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY,
- DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA = VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA,
- DEPTH_DRAW_NEVER = VS::MATERIAL_DEPTH_DRAW_NEVER
- };
-
-
-
-private:
- BlendMode blend_mode;
- bool flags[VS::MATERIAL_FLAG_MAX];
- float line_width;
- DepthDrawMode depth_draw_mode;
-protected:
RID material;
-
- static void _bind_methods();
-
public:
- void set_flag(Flag p_flag,bool p_enabled);
- bool get_flag(Flag p_flag) const;
-
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
-
- void set_depth_draw_mode(DepthDrawMode p_depth_draw_mode);
- DepthDrawMode get_depth_draw_mode() const;
-
- void set_line_width(float p_width);
- float get_line_width() const;
virtual RID get_rid() const;
-
- Material(const RID& p_rid=RID());
+ Material();
virtual ~Material();
};
-VARIANT_ENUM_CAST( Material::Flag );
-VARIANT_ENUM_CAST( Material::DepthDrawMode );
-
-VARIANT_ENUM_CAST( Material::BlendMode );
-
class FixedMaterial : public Material {
- OBJ_TYPE( FixedMaterial, Material );
- REVERSE_GET_PROPERTY_LIST
-public:
-
- enum Parameter {
- PARAM_DIFFUSE=VS::FIXED_MATERIAL_PARAM_DIFFUSE,
- PARAM_DETAIL=VS::FIXED_MATERIAL_PARAM_DETAIL,
- PARAM_SPECULAR=VS::FIXED_MATERIAL_PARAM_SPECULAR,
- PARAM_EMISSION=VS::FIXED_MATERIAL_PARAM_EMISSION,
- PARAM_SPECULAR_EXP=VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP,
- PARAM_GLOW=VS::FIXED_MATERIAL_PARAM_GLOW,
- PARAM_NORMAL=VS::FIXED_MATERIAL_PARAM_NORMAL,
- PARAM_SHADE_PARAM=VS::FIXED_MATERIAL_PARAM_SHADE_PARAM,
- PARAM_MAX=VS::FIXED_MATERIAL_PARAM_MAX
- };
-
-
- enum TexCoordMode {
-
- TEXCOORD_UV=VS::FIXED_MATERIAL_TEXCOORD_UV,
- TEXCOORD_UV_TRANSFORM=VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM,
- TEXCOORD_UV2=VS::FIXED_MATERIAL_TEXCOORD_UV2,
- TEXCOORD_SPHERE=VS::FIXED_MATERIAL_TEXCOORD_SPHERE
- };
-
- enum FixedFlag {
- FLAG_USE_ALPHA=VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
- FLAG_USE_COLOR_ARRAY=VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
- FLAG_USE_POINT_SIZE=VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
- FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA,
- FLAG_USE_XY_NORMALMAP=VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP,
- FLAG_MAX=VS::FIXED_MATERIAL_FLAG_MAX
- };
-
- enum LightShader {
-
- LIGHT_SHADER_LAMBERT=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
- LIGHT_SHADER_WRAP=VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP,
- LIGHT_SHADER_VELVET=VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET,
- LIGHT_SHADER_TOON=VS::FIXED_MATERIAL_LIGHT_SHADER_TOON
- };
-
-private:
-
-
- struct Node {
-
- int param;
- int mult;
- int tex;
- };
-
- Variant param[PARAM_MAX];
- Ref<Texture> texture_param[PARAM_MAX];
- TexCoordMode texture_texcoord[PARAM_MAX];
- LightShader light_shader;
- bool fixed_flags[FLAG_MAX];
- float point_size;
-
-
- Transform uv_transform;
-
-protected:
-
-
- static void _bind_methods();
+ OBJ_TYPE(FixedMaterial,Resource);
public:
- void set_fixed_flag(FixedFlag p_flag, bool p_value);
- bool get_fixed_flag(FixedFlag p_flag) const;
-
- void set_parameter(Parameter p_parameter, const Variant& p_value);
- Variant get_parameter(Parameter p_parameter) const;
-
- void set_texture(Parameter p_parameter, Ref<Texture> p_texture);
- Ref<Texture> get_texture(Parameter p_parameter) const;
-
- void set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode);
- TexCoordMode get_texcoord_mode(Parameter p_parameter) const;
-
- void set_light_shader(LightShader p_shader);
- LightShader get_light_shader() const;
-
- void set_uv_transform(const Transform& p_transform);
- Transform get_uv_transform() const;
-
- void set_point_size(float p_transform);
- float get_point_size() const;
-
FixedMaterial();
- ~FixedMaterial();
-
+ virtual ~FixedMaterial();
};
-
-VARIANT_ENUM_CAST( FixedMaterial::Parameter );
-VARIANT_ENUM_CAST( FixedMaterial::TexCoordMode );
-VARIANT_ENUM_CAST( FixedMaterial::FixedFlag );
-VARIANT_ENUM_CAST( FixedMaterial::LightShader );
-
-class ShaderMaterial : public Material {
-
- OBJ_TYPE( ShaderMaterial, Material );
-
- Ref<Shader> shader;
-
-
-
- void _shader_changed();
- static void _shader_parse(void*p_self,ShaderLanguage::ProgramNode*p_node);
-
-protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
-
- static void _bind_methods();
-
-public:
-
- void set_shader(const Ref<Shader>& p_shader);
- Ref<Shader> get_shader() const;
-
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
-
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
-
- ShaderMaterial();
-};
-
//////////////////////
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 921466585d..132ec54e48 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -122,22 +122,14 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (idx==surfaces.size()) {
- if (what=="custom") {
- add_custom_surface(p_value);
- return true;
-
- }
-
//create
Dictionary d=p_value;
ERR_FAIL_COND_V(!d.has("primitive"),false);
ERR_FAIL_COND_V(!d.has("arrays"),false);
ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
- bool alphasort = d.has("alphasort") && bool(d["alphasort"]);
-
- add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort);
+ add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]);
if (d.has("material")) {
surface_set_material(idx,d["material"]);
@@ -196,7 +188,6 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
d["primitive"]=surface_get_primitive_type(idx);
d["arrays"]=surface_get_arrays(idx);
d["morph_arrays"]=surface_get_morph_arrays(idx);
- d["alphasort"]=surface_is_alpha_sorting_enabled(idx);
Ref<Material> m = surface_get_material(idx);
if (m.is_valid())
d["material"]=m;
@@ -243,14 +234,14 @@ void Mesh::_recompute_aabb() {
}
-void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,bool p_alphasort) {
+void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes) {
ERR_FAIL_COND(p_arrays.size()!=ARRAY_MAX);
Surface s;
- VisualServer::get_singleton()->mesh_add_surface(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_alphasort);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes);
surfaces.push_back(s);
@@ -274,7 +265,6 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
}
surfaces[surfaces.size()-1].aabb=aabb;
- surfaces[surfaces.size()-1].alphasort=p_alphasort;
_recompute_aabb();
@@ -289,29 +279,19 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
Array Mesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh,p_surface);
+ //return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh,p_surface);
+ return Array();
}
Array Mesh::surface_get_morph_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_morph_arrays(mesh,p_surface);
+ return Array();
}
-void Mesh::add_custom_surface(const Variant& p_data) {
-
- Surface s;
- s.aabb=AABB();
- VisualServer::get_singleton()->mesh_add_custom_surface(mesh,p_data);
- surfaces.push_back(s);
-
- triangle_mesh=Ref<TriangleMesh>();
- _change_notify();
-}
-
int Mesh::get_surface_count() const {
@@ -418,11 +398,6 @@ Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const {
return (PrimitiveType)VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, p_idx );
}
-bool Mesh::surface_is_alpha_sorting_enabled(int p_idx) const {
-
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), 0 );
- return surfaces[p_idx].alphasort;
-}
void Mesh::surface_set_material(int p_idx, const Ref<Material>& p_material) {
@@ -968,7 +943,6 @@ void Mesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_morph_target_mode","mode"),&Mesh::set_morph_target_mode);
ObjectTypeDB::bind_method(_MD("get_morph_target_mode"),&Mesh::get_morph_target_mode);
- ObjectTypeDB::bind_method(_MD("add_surface","primitive","arrays","morph_arrays","alphasort"),&Mesh::add_surface,DEFVAL(Array()),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
ObjectTypeDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
ObjectTypeDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index dc1d97a49e..e329c353a0 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -99,7 +99,6 @@ private:
struct Surface {
String name;
AABB aabb;
- bool alphasort;
Ref<Material> material;
};
Vector<Surface> surfaces;
@@ -123,12 +122,10 @@ protected:
public:
- void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alphasort=false);
+ void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array());
Array surface_get_arrays(int p_surface) const;
virtual Array surface_get_morph_arrays(int p_surface) const;
- void add_custom_surface(const Variant& p_data); //only recognized by driver
-
void add_morph_target(const StringName& p_name);
int get_morph_target_count() const;
StringName get_morph_target_name(int p_index) const;
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index c5ade63124..0a005d8c54 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -141,7 +141,7 @@ Ref<Mesh> MultiMesh::get_mesh() const {
void MultiMesh::set_instance_count(int p_count) {
- VisualServer::get_singleton()->multimesh_set_instance_count(multimesh,p_count);
+ VisualServer::get_singleton()->multimesh_allocate(multimesh,p_count,VS::MultimeshTransformFormat(transform_format),VS::MultimeshColorFormat(color_format));
}
int MultiMesh::get_instance_count() const {
@@ -177,7 +177,7 @@ Color MultiMesh::get_instance_color(int p_instance) const {
void MultiMesh::set_aabb(const AABB& p_aabb) {
aabb=p_aabb;
- VisualServer::get_singleton()->multimesh_set_aabb(multimesh,p_aabb);
+ VisualServer::get_singleton()->multimesh_set_custom_aabb(multimesh,p_aabb);
}
@@ -220,10 +220,36 @@ RID MultiMesh::get_rid() const {
}
+
+void MultiMesh::set_color_format(ColorFormat p_color_format) {
+
+ color_format=p_color_format;
+}
+
+MultiMesh::ColorFormat MultiMesh::get_color_format() const{
+
+ return color_format;
+}
+
+void MultiMesh::set_transform_format(TransformFormat p_transform_format){
+
+ transform_format=p_transform_format;
+}
+MultiMesh::TransformFormat MultiMesh::get_transform_format() const{
+
+ return transform_format;
+}
+
+
void MultiMesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
+ ObjectTypeDB::bind_method(_MD("set_color_format","format"),&MultiMesh::set_color_format);
+ ObjectTypeDB::bind_method(_MD("get_color_format"),&MultiMesh::get_color_format);
+ ObjectTypeDB::bind_method(_MD("set_transform_format","format"),&MultiMesh::set_transform_format);
+ ObjectTypeDB::bind_method(_MD("get_transform_format"),&MultiMesh::get_transform_format);
+
ObjectTypeDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
ObjectTypeDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
ObjectTypeDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
@@ -241,17 +267,29 @@ void MultiMesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"color_format",PROPERTY_HINT_ENUM,"None,Byte,Float"), _SCS("set_color_format"), _SCS("get_color_format"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"transform_format",PROPERTY_HINT_ENUM,"None,2D,3D"), _SCS("set_transform_format"), _SCS("get_transform_format"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
ADD_PROPERTY(PropertyInfo(Variant::_AABB,"aabb"), _SCS("set_aabb"), _SCS("get_aabb") );
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+
+ BIND_CONSTANT( TRANSFORM_NONE );
+ BIND_CONSTANT( TRANSFORM_2D );
+ BIND_CONSTANT( TRANSFORM_3D );
+ BIND_CONSTANT( COLOR_NONE );
+ BIND_CONSTANT( COLOR_8BIT );
+ BIND_CONSTANT( COLOR_FLOAT );
+
}
MultiMesh::MultiMesh() {
multimesh = VisualServer::get_singleton()->multimesh_create();
+ color_format=COLOR_NONE;
+ transform_format=TRANSFORM_NONE;
}
MultiMesh::~MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 0cf9e92def..be4ee38fcd 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -30,16 +30,33 @@
#define MULTIMESH_H
#include "scene/resources/mesh.h"
-
+#include "servers/visual_server.h"
class MultiMesh : public Resource {
OBJ_TYPE( MultiMesh, Resource );
RES_BASE_EXTENSION("mmsh");
+public:
+ enum TransformFormat {
+ TRANSFORM_NONE = VS::MULTIMESH_TRANSFORM_NONE,
+ TRANSFORM_2D = VS::MULTIMESH_TRANSFORM_2D,
+ TRANSFORM_3D = VS::MULTIMESH_TRANSFORM_3D
+ };
+
+ enum ColorFormat {
+ COLOR_NONE = VS::MULTIMESH_COLOR_NONE,
+ COLOR_8BIT = VS::MULTIMESH_COLOR_8BIT,
+ COLOR_FLOAT = VS::MULTIMESH_COLOR_FLOAT,
+ };
+private:
AABB aabb;
Ref<Mesh> mesh;
RID multimesh;
+ TransformFormat transform_format;
+ ColorFormat color_format;
+
+
protected:
static void _bind_methods();
@@ -55,6 +72,12 @@ public:
void set_mesh(const Ref<Mesh>& p_mesh);
Ref<Mesh> get_mesh() const;
+ void set_color_format(ColorFormat p_color_format);
+ ColorFormat get_color_format() const;
+
+ void set_transform_format(TransformFormat p_transform_format);
+ TransformFormat get_transform_format() const;
+
void set_instance_count(int p_count);
int get_instance_count() const;
@@ -76,4 +99,8 @@ public:
};
+
+VARIANT_ENUM_CAST( MultiMesh::TransformFormat );
+VARIANT_ENUM_CAST( MultiMesh::ColorFormat);
+
#endif // MULTI_MESH_H
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index f28220531b..978a15ab5e 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -36,16 +36,6 @@ RID RoomBounds::get_rid() const {
return area;
}
-void RoomBounds::set_bounds( const BSP_Tree& p_bounds ) {
-
- VisualServer::get_singleton()->room_set_bounds(area,p_bounds);
- emit_signal("changed");
-}
-
-BSP_Tree RoomBounds::get_bounds() const {
-
- return VisualServer::get_singleton()->room_get_bounds(area);
-}
void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) {
@@ -57,41 +47,15 @@ DVector<Face3> RoomBounds::get_geometry_hint() const {
return geometry_hint;
}
-void RoomBounds::_regenerate_bsp_cubic() {
-
- if (geometry_hint.size()) {
-
- float err=0;
- geometry_hint= Geometry::wrap_geometry( geometry_hint, &err ); ///< create a "wrap" that encloses the given geometry
- BSP_Tree new_bounds(geometry_hint,err);
- set_bounds(new_bounds);
- }
-
-}
-
-void RoomBounds::_regenerate_bsp() {
-
- if (geometry_hint.size()) {
-
- BSP_Tree new_bounds(geometry_hint,0);
- set_bounds(new_bounds);
- }
-}
void RoomBounds::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bounds","bsp_tree"),&RoomBounds::set_bounds);
- ObjectTypeDB::bind_method(_MD("get_bounds"),&RoomBounds::get_bounds);
ObjectTypeDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
ObjectTypeDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp"),&RoomBounds::_regenerate_bsp);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp_cubic"),&RoomBounds::_regenerate_bsp_cubic);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp_cubic"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
+ //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
}
diff --git a/scene/resources/room.h b/scene/resources/room.h
index dc5e284838..6200521044 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -34,6 +34,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class RoomBounds : public Resource {
OBJ_TYPE( RoomBounds, Resource );
@@ -42,8 +43,7 @@ class RoomBounds : public Resource {
RID area;
DVector<Face3> geometry_hint;
- void _regenerate_bsp();
- void _regenerate_bsp_cubic();
+
protected:
static void _bind_methods();
@@ -52,8 +52,6 @@ public:
virtual RID get_rid() const;
- void set_bounds( const BSP_Tree& p_bounds );
- BSP_Tree get_bounds() const;
void set_geometry_hint(const DVector<Face3>& geometry_hint);
DVector<Face3> get_geometry_hint() const;
@@ -63,4 +61,6 @@ public:
};
+
+
#endif // ROOM_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index ee9f23dd2a..b6c8fcf7a1 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -39,37 +39,17 @@ Shader::Mode Shader::get_mode() const {
return mode;
}
-void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) {
+void Shader::set_code(const String& p_code) {
- VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_light,0,p_fragment_ofs,p_light_ofs);
+ VisualServer::get_singleton()->shader_set_code(shader,p_code);
params_cache_dirty=true;
emit_signal(SceneStringNames::get_singleton()->changed);
}
-String Shader::get_vertex_code() const {
+String Shader::get_code() const {
- return VisualServer::get_singleton()->shader_get_vertex_code(shader);
-}
-
-String Shader::get_fragment_code() const {
-
- return VisualServer::get_singleton()->shader_get_fragment_code(shader);
-
-}
-
-String Shader::get_light_code() const {
-
- return VisualServer::get_singleton()->shader_get_light_code(shader);
-
-}
-
-bool Shader::has_param(const StringName& p_param) const {
-
- if (params_cache_dirty)
- get_param_list(NULL);
-
- return (params_cache.has(p_param));
+ return VisualServer::get_singleton()->shader_get_code(shader);
}
@@ -101,48 +81,6 @@ RID Shader::get_rid() const {
return shader;
}
-Dictionary Shader::_get_code() {
-
- String fs = VisualServer::get_singleton()->shader_get_fragment_code(shader);
- String vs = VisualServer::get_singleton()->shader_get_vertex_code(shader);
- String ls = VisualServer::get_singleton()->shader_get_light_code(shader);
-
- Dictionary c;
- c["fragment"]=fs;
- c["fragment_ofs"]=0;
- c["vertex"]=vs;
- c["vertex_ofs"]=0;
- c["light"]=ls;
- c["light_ofs"]=0;
- Array arr;
- for(const Map<StringName,Ref<Texture> >::Element *E=default_textures.front();E;E=E->next()) {
- arr.push_back(E->key());
- arr.push_back(E->get());
- }
- if (arr.size())
- c["default_tex"]=arr;
- return c;
-}
-
-void Shader::_set_code(const Dictionary& p_string) {
-
- ERR_FAIL_COND(!p_string.has("fragment"));
- ERR_FAIL_COND(!p_string.has("vertex"));
- String light;
- if (p_string.has("light"))
- light=p_string["light"];
-
- set_code(p_string["vertex"],p_string["fragment"],light);
- if (p_string.has("default_tex")) {
- Array arr=p_string["default_tex"];
- if ((arr.size()&1)==0) {
- for(int i=0;i<arr.size();i+=2) {
-
- set_default_texture_param(arr[i],arr[i+1]);
- }
- }
- }
-}
void Shader::set_default_texture_param(const StringName& p_param,const Ref<Texture>& p_texture) {
@@ -171,29 +109,27 @@ void Shader::get_default_texture_param_list(List<StringName>* r_textures) const{
}
}
+bool Shader::has_param(const StringName& p_param) const {
+ return params_cache.has(p_param);
+}
void Shader::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_mode"),&Shader::get_mode);
- ObjectTypeDB::bind_method(_MD("set_code","vcode","fcode","lcode","fofs","lofs"),&Shader::set_code,DEFVAL(0),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("get_vertex_code"),&Shader::get_vertex_code);
- ObjectTypeDB::bind_method(_MD("get_fragment_code"),&Shader::get_fragment_code);
- ObjectTypeDB::bind_method(_MD("get_light_code"),&Shader::get_light_code);
+ ObjectTypeDB::bind_method(_MD("set_code","code"),&Shader::set_code);
+ ObjectTypeDB::bind_method(_MD("get_code"),&Shader::get_code);
ObjectTypeDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
ObjectTypeDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
ObjectTypeDB::bind_method(_MD("has_param","name"),&Shader::has_param);
- ObjectTypeDB::bind_method(_MD("_set_code","code"),&Shader::_set_code);
- ObjectTypeDB::bind_method(_MD("_get_code"),&Shader::_get_code);
-
//ObjectTypeDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
- ADD_PROPERTY( PropertyInfo(Variant::STRING, "_code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_code"), _SCS("_get_code") );
+ ADD_PROPERTY( PropertyInfo(Variant::STRING, "code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("set_code"), _SCS("get_code") );
BIND_CONSTANT( MODE_MATERIAL );
BIND_CONSTANT( MODE_CANVAS_ITEM );
@@ -214,253 +150,3 @@ Shader::~Shader() {
}
-
-/************ Loader from text ***************/
-
-
-
-RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_original_path, Error *r_error) {
-
- if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
-
- String fragment_code;
- String vertex_code;
- String light_code;
-
- int mode=-1;
-
- Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
-
-
- ERR_EXPLAIN("Unable to open shader file: "+p_path);
- ERR_FAIL_COND_V(err,RES());
- String base_path = p_path.get_base_dir();
-
- if (r_error)
- *r_error=ERR_FILE_CORRUPT;
-
- Ref<Shader> shader;//( memnew( Shader ) );
-
- int line=0;
-
- while(!f->eof_reached()) {
-
- String l = f->get_line();
- line++;
-
- if (mode<=0) {
- l = l.strip_edges();
- int comment = l.find(";");
- if (comment!=-1)
- l=l.substr(0,comment);
- }
-
- if (mode<1)
- vertex_code+="\n";
- if (mode<2)
- fragment_code+="\n";
-
- if (mode < 1 && l=="")
- continue;
-
- if (l.begins_with("[")) {
- l=l.strip_edges();
- if (l=="[params]") {
- if (mode>=0) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [params] section.");
- ERR_FAIL_V(RES());
- }
- mode=0;
- } else if (l=="[vertex]") {
- if (mode>=1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [vertex] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else if (l=="[fragment]") {
- if (mode>=2) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [fragment] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Unknown section type: '"+l+"'.");
- ERR_FAIL_V(RES());
- }
- continue;
- }
-
- if (mode==0) {
-
- int eqpos = l.find("=");
- if (eqpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected '='.");
- ERR_FAIL_V(RES());
- }
-
-
- String right=l.substr(eqpos+1,l.length()).strip_edges();
- if (right=="") {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected value after '='.");
- ERR_FAIL_V(RES());
- }
-
- Variant value;
-
- if (right=="true") {
- value = true;
- } else if (right=="false") {
- value = false;
- } else if (right.is_valid_float()) {
- //is number
- value = right.to_double();
- } else if (right.is_valid_html_color()) {
- //is html color
- value = Color::html(right);
- } else {
- //attempt to parse a constructor
- int popenpos = right.find("(");
-
- if (popenpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor syntax: "+right);
- ERR_FAIL_V(RES());
- }
-
- int pclosepos = right.find_last(")");
-
- if (pclosepos==-1) {
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor parameter syntax: "+right);
- ERR_FAIL_V(RES());
-
- }
-
- String type = right.substr(0,popenpos);
- String param = right.substr(popenpos+1,pclosepos-popenpos-1).strip_edges();
-
-
- if (type=="tex") {
-
- if (param=="") {
-
- value=RID();
- } else {
-
- String path;
-
- if (param.is_abs_path())
- path=param;
- else
- path=base_path+"/"+param;
-
- Ref<Texture> texture = ResourceLoader::load(path);
- if (!texture.is_valid()) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find icon at path: "+path);
- ERR_FAIL_V(RES());
- }
-
- value=texture;
- }
-
- } else if (type=="vec3") {
-
- if (param=="") {
- value=Vector3();
- } else {
- Vector<String> params = param.split(",");
- if (params.size()!=3) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for vec3(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Vector3 v;
- for(int i=0;i<3;i++)
- v[i]=params[i].to_double();
- value=v;
- }
-
-
- } else if (type=="xform") {
-
- if (param=="") {
- value=Transform();
- } else {
-
- Vector<String> params = param.split(",");
- if (params.size()!=12) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for xform(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Transform t;
- for(int i=0;i<9;i++)
- t.basis[i%3][i/3]=params[i].to_double();
- for(int i=0;i<3;i++)
- t.origin[i]=params[i-9].to_double();
-
- value=t;
- }
-
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor type: '"+type+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- }
-
- String left= l.substr(0,eqpos);
-
-// shader->set_param(left,value);
- } else if (mode==1) {
-
- vertex_code+=l;
-
- } else if (mode==2) {
-
- fragment_code+=l;
- }
- }
-
- shader->set_code(vertex_code,fragment_code,light_code);
-
- f->close();
- memdelete(f);
- if (r_error)
- *r_error=OK;
-
- return shader;
-}
-
-void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
-
- ObjectTypeDB::get_extensions_for_type("Shader", p_extensions);
-}
-
-bool ResourceFormatLoaderShader::handles_type(const String& p_type) const {
-
- return ObjectTypeDB::is_type(p_type, "Shader");
-}
-
-
-String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
-
- if (p_path.extension().to_lower()=="shd")
- return "Shader";
- return "";
-}
-
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 6ee8d4e793..988305b654 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -32,6 +32,7 @@
#include "resource.h"
#include "io/resource_loader.h"
#include "scene/resources/texture.h"
+
class Shader : public Resource {
OBJ_TYPE(Shader,Resource);
@@ -49,9 +50,6 @@ public:
private:
RID shader;
Mode mode;
- Dictionary _get_code();
- void _set_code(const Dictionary& p_string);
-
// hack the name of performance
// shaders keep a list of ShaderMaterial -> VisualServer name translations, to make
@@ -73,10 +71,8 @@ public:
//void set_mode(Mode p_mode);
Mode get_mode() const;
- void set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs=0,int p_light_ofs=0);
- String get_vertex_code() const;
- String get_fragment_code() const;
- String get_light_code() const;
+ void set_code( const String& p_code);
+ String get_code() const;
void get_param_list(List<PropertyInfo> *p_params) const;
bool has_param(const StringName& p_param) const;
@@ -124,14 +120,5 @@ public:
-class ResourceFormatLoaderShader : public ResourceFormatLoader {
-public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
-
-
#endif // SHADER_H
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 02faa9425d..c62479ca89 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -29,6 +29,7 @@
#include "shader_graph.h"
#include "scene/scene_string_names.h"
+#if 0
Array ShaderGraph::_get_node_list(ShaderType p_type) const {
List<int> nodes;
@@ -2489,7 +2490,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
}
}
- Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA,cramp);
+ Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA8,cramp);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2559,7 +2560,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
- Image gradient(curve_map_len,1,0,Image::FORMAT_GRAYSCALE,cmap);
+ Image gradient(curve_map_len,1,0,Image::FORMAT_L8,cmap);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2660,3 +2661,5 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
#undef DEF_MATRIX
#undef DEF_VEC
}
+
+#endif
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index 1e6fc3507c..d5a5102f3a 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -30,7 +30,7 @@
#define SHADER_GRAPH_H
-
+#if 0
#include "map.h"
#include "scene/resources/shader.h"
@@ -440,5 +440,5 @@ public:
}
};
-
+#endif
#endif // SHADER_GRAPH_H
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 59246dfabe..34d66df915 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -141,7 +141,7 @@ void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const {
r.pos.y-=expand_margin[MARGIN_TOP];
r.size.x+=expand_margin[MARGIN_LEFT]+expand_margin[MARGIN_RIGHT];
r.size.y+=expand_margin[MARGIN_TOP]+expand_margin[MARGIN_BOTTOM];
- VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
+ VisualServer::get_singleton()->canvas_item_add_nine_patch( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center,modulate);
}
void StyleBoxTexture::set_draw_center(bool p_draw) {
@@ -423,127 +423,3 @@ StyleBoxFlat::~StyleBoxFlat() {
}
-////////////////
-
-
-
-void StyleBoxImageMask::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_image","image"),&StyleBoxImageMask::set_image);
- ObjectTypeDB::bind_method(_MD("get_image"),&StyleBoxImageMask::get_image);
- ObjectTypeDB::bind_method(_MD("set_expand","expand"),&StyleBoxImageMask::set_expand);
- ObjectTypeDB::bind_method(_MD("get_expand"),&StyleBoxImageMask::get_expand);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxImageMask::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxImageMask::get_expand_margin_size);
-
- ADD_PROPERTY( PropertyInfo(Variant::IMAGE, "image"), _SCS("set_image"), _SCS("get_image"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("get_expand"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
-
-}
-
-
-bool StyleBoxImageMask::test_mask(const Point2& p_point, const Rect2& p_rect) const {
-
- if (image.empty())
- return false;
- if (p_rect.size.x<1)
- return false;
- if (p_rect.size.y<1)
- return false;
-
- Size2i imgsize(image.get_width(),image.get_height());
- if (imgsize.x<=0 || imgsize.y<=0)
- return false;
-
- Point2i img_expand_size( imgsize.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], imgsize.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- Point2i rect_expand_size( p_rect.size.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], p_rect.size.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- if (rect_expand_size.x<1)
- rect_expand_size.x=1;
- if (rect_expand_size.y<1)
- rect_expand_size.y=1;
-
-
- Point2i click_pos;
-
-
- //treat x
-
- if (p_point.x<p_rect.pos.x)
- click_pos.x=0;
- else if (expand) {
-
- if (p_point.x>=p_rect.pos.x+p_rect.size.x)
- click_pos.x=imgsize.x-1;
- else if ((p_point.x-p_rect.pos.x)<expand_margin[MARGIN_LEFT])
- click_pos.x=p_point.x;
- else if ((p_point.x-(p_rect.pos.x+p_rect.size.x))<expand_margin[MARGIN_RIGHT])
- click_pos.x=imgsize.x-(p_point.x-(p_rect.pos.x+p_rect.size.x));
- else //expand
- click_pos.x=(p_point.x-p_rect.pos.x-expand_margin[MARGIN_LEFT])*img_expand_size.x/rect_expand_size.x;
- } else if ((p_point.x-p_rect.pos.x) > imgsize.x)
- click_pos.x=imgsize.x;
-
- //treat y
-
- if (p_point.y<p_rect.pos.y)
- click_pos.y=0;
- else if (expand) {
-
- if (p_point.y>=p_rect.pos.y+p_rect.size.y)
- click_pos.y=imgsize.y-1;
- else if ((p_point.y-p_rect.pos.y)<expand_margin[MARGIN_TOP])
- click_pos.y=p_point.y;
- else if ((p_point.y-(p_rect.pos.y+p_rect.size.y))<expand_margin[MARGIN_BOTTOM])
- click_pos.y=imgsize.y-(p_point.y-(p_rect.pos.y+p_rect.size.y));
- else //expand
- click_pos.y=(p_point.y-p_rect.pos.y-expand_margin[MARGIN_TOP])*img_expand_size.y/rect_expand_size.y;
- } else if ((p_point.y-p_rect.pos.y) > imgsize.y)
- click_pos.y=imgsize.y;
-
- return image.get_pixel(click_pos.x,click_pos.y).gray()>0.5;
-
-}
-
-
-void StyleBoxImageMask::set_image(const Image& p_image) {
-
- image=p_image;
-}
-Image StyleBoxImageMask::get_image() const {
-
- return image;
-}
-
-
-void StyleBoxImageMask::set_expand(bool p_expand) {
-
- expand=p_expand;
-}
-bool StyleBoxImageMask::get_expand() const {
-
- return expand;
-}
-void StyleBoxImageMask::set_expand_margin_size(Margin p_expand_margin,float p_size) {
-
- ERR_FAIL_INDEX(p_expand_margin,4);
- expand_margin[p_expand_margin]=p_size;
-}
-
-
-float StyleBoxImageMask::get_expand_margin_size(Margin p_expand_margin) const {
-
- ERR_FAIL_INDEX_V(p_expand_margin,4,0);
- return expand_margin[p_expand_margin];
-}
-
-StyleBoxImageMask::StyleBoxImageMask() {
-
- for (int i=0;i<4;i++) {
- expand_margin[i]=0;
- }
- expand=true;
-}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index f667318e24..6ac67148c5 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -167,35 +167,5 @@ public:
};
-class StyleBoxImageMask : public StyleBox {
-
- OBJ_TYPE( StyleBoxImageMask, StyleBox );
- virtual float get_style_margin(Margin p_margin) const { return 0; }
-
- Image image;
- float expand_margin[4];
- bool expand;
-
-protected:
-
- static void _bind_methods();
-
-public:
-
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {}
- virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const;
-
- void set_image(const Image& p_image);
- Image get_image() const;
-
- void set_expand(bool p_expand);
- bool get_expand() const;
- void set_expand_margin_size(Margin p_expand_margin,float p_size);
- float get_expand_margin_size(Margin p_expand_margin) const;
-
- StyleBoxImageMask();
-
-};
-
#endif
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 726b1938c4..c83c5e6b80 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -258,23 +258,13 @@ void ImageTexture::load(const String& p_path) {
void ImageTexture::set_data(const Image& p_image) {
VisualServer::get_singleton()->texture_set_data(texture,p_image);
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName()); //hook is erased if data is changed
+
_change_notify();
}
void ImageTexture::_resource_path_changed() {
String path=get_path();
- if (VS::get_singleton()->has_feature(VS::FEATURE_NEEDS_RELOAD_HOOK)) {
- //this needs to be done much better, but probably will end up being deprecated as technology advances
- if (path.is_resource_file() && ImageLoader::recognize(path.extension())) {
-
- //hook is set only if path is hookable
- VisualServer::get_singleton()->texture_set_reload_hook(texture,get_instance_ID(),"_reload_hook");
- } else {
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName());
- }
- }
}
Image ImageTexture::get_data() const {
@@ -300,7 +290,7 @@ RID ImageTexture::get_rid() const {
void ImageTexture::fix_alpha_edges() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.fix_alpha_edges();
@@ -310,7 +300,7 @@ void ImageTexture::fix_alpha_edges() {
void ImageTexture::premultiply_alpha() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.premultiply_alpha();
@@ -337,7 +327,7 @@ void ImageTexture::shrink_x2_and_keep_size() {
bool ImageTexture::has_alpha() const {
- return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
+ return ( format==Image::FORMAT_LA8 || format==Image::FORMAT_RGBA8 );
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 05ea833978..fc5f05479c 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -54,7 +54,7 @@ public:
FLAG_FILTER=VisualServer::TEXTURE_FLAG_FILTER,
FLAG_ANISOTROPIC_FILTER=VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
FLAG_CONVERT_TO_LINEAR=VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_VIDEO_SURFACE,
+ FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_USED_FOR_STREAMING,
FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER,
FLAG_MIRRORED_REPEAT=VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
};