summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorAnton Yabchinskiy <arn@bestmx.ru>2015-02-17 15:57:24 +0300
committerAnton Yabchinskiy <arn@bestmx.ru>2015-02-17 15:57:24 +0300
commite024ff89b224f803fe335efa95d3e99bffc3423f (patch)
tree84ca5323c97ef24cfcae202447ac6967783e9248 /servers
parent6f93e6812edaf6c8c79c28dadbe5f1c4a8ced93e (diff)
parent2bea642583efeb68886e71950384f297f2d7ee12 (diff)
Merge branch 'master' of https://github.com/okamstudio/godot
Diffstat (limited to 'servers')
-rw-r--r--servers/visual/rasterizer.h33
-rw-r--r--servers/visual/visual_server_raster.cpp134
-rw-r--r--servers/visual/visual_server_raster.h36
-rw-r--r--servers/visual/visual_server_wrap_mt.h23
-rw-r--r--servers/visual_server.h33
5 files changed, 259 insertions, 0 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 92c7b8ac14..63ebdbc34a 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -567,6 +567,39 @@ public:
CANVAS_RECT_FLIP_V=8
};
+
+ struct CanvasLight {
+
+ bool enabled;
+ bool shadow;
+ Color color;
+ Matrix32 xform;
+ float height;
+ int z_min;
+ int z_max;
+ int item_mask;
+ VS::CanvasLightBlendMode blend_mode;
+ RID texture;
+ void *texture_cache; // implementation dependent
+ Vector2 texture_offset;
+
+ CanvasLight *next_ptr;
+
+ CanvasLight() {
+ enabled=true;
+ shadow=false;
+ color=Color(1,1,1);
+ height=0;
+ z_min=-1024;
+ z_max=1024;
+ item_mask=1;
+ blend_mode=VS::CANVAS_LIGHT_BLEND_ADD;
+ texture_cache=NULL;
+ next_ptr=NULL;
+ }
+ };
+
+
struct CanvasItem {
struct Command {
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index a3aa573e35..e8fa319f11 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -3819,6 +3819,131 @@ void VisualServerRaster::canvas_item_raise(RID p_item) {
}
+/***** CANVAS LIGHT *******/
+
+RID VisualServerRaster::canvas_light_create() {
+
+ Rasterizer::CanvasLight *clight = memnew( Rasterizer::CanvasLight );
+ return canvas_light_owner.make_rid(clight);
+}
+
+void VisualServerRaster::canvas_light_attach_to_canvas(RID p_light,RID p_canvas){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+
+
+}
+void VisualServerRaster::canvas_light_set_enabled(RID p_light, bool p_enabled){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->enabled=p_enabled;
+
+}
+void VisualServerRaster::canvas_light_set_transform(RID p_light, const Matrix32& p_transform){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->xform=p_transform;
+
+}
+void VisualServerRaster::canvas_light_set_texture(RID p_light, RID p_texture){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->texture=p_texture;
+
+}
+void VisualServerRaster::canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->texture_offset=p_offset;
+
+}
+void VisualServerRaster::canvas_light_set_color(RID p_light, const Color& p_color){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->color=p_color;
+
+
+}
+void VisualServerRaster::canvas_light_set_height(RID p_light, float p_height){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->height=p_height;
+
+}
+void VisualServerRaster::canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->z_min=p_min_z;
+ clight->z_max=p_max_z;
+
+}
+void VisualServerRaster::canvas_light_set_item_mask(RID p_light, int p_mask){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->item_mask=p_mask;
+
+}
+
+void VisualServerRaster::canvas_light_set_blend_mode(RID p_light, CanvasLightBlendMode p_blend_mode){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->blend_mode=p_blend_mode;
+
+}
+void VisualServerRaster::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->shadow=p_enabled;
+
+}
+void VisualServerRaster::canvas_light_set_shadow_buffer_size(RID p_light, int p_size){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+
+}
+void VisualServerRaster::canvas_light_set_shadow_filter(RID p_light, int p_size){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+
+}
+
+/****** CANVAS LIGHT OCCLUDER ******/
+
+RID VisualServerRaster::canvas_light_occluder_create() {
+
+ return RID();
+}
+
+void VisualServerRaster::canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas) {
+
+
+}
+
+void VisualServerRaster::canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled){
+
+
+}
+
+void VisualServerRaster::canvas_light_occluder_set_shape(RID p_occluder,const DVector<Vector2>& p_shape){
+
+
+}
+
+
+
/******** CANVAS *********/
@@ -4101,6 +4226,15 @@ void VisualServerRaster::free( RID p_rid ) {
canvas_item_owner.free( p_rid );
memdelete( canvas_item );
+
+ } else if (canvas_light_owner.owns(p_rid)) {
+
+ Rasterizer::CanvasLight *canvas_light = canvas_light_owner.get(p_rid);
+ ERR_FAIL_COND(!canvas_light);
+
+ canvas_light_owner.free( p_rid );
+ memdelete( canvas_light );
+
} else if (scenario_owner.owns(p_rid)) {
Scenario *scenario=scenario_owner.get(p_rid);
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 6c4e15827a..c15b6ebb26 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -440,6 +440,8 @@ class VisualServerRaster : public VisualServer {
};
+ RID_Owner<Rasterizer::CanvasLight> canvas_light_owner;
+
struct Viewport {
@@ -1122,9 +1124,43 @@ public:
virtual void canvas_item_set_use_parent_shader(RID p_item, bool p_enable);
+
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value);
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const;
+ virtual RID canvas_light_create();
+ virtual void canvas_light_attach_to_canvas(RID p_light,RID p_canvas);
+ virtual void canvas_light_set_enabled(RID p_light, bool p_enabled);
+ virtual void canvas_light_set_transform(RID p_light, const Matrix32& p_transform);
+ virtual void canvas_light_set_texture(RID p_light, RID p_texture);
+ virtual void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset);
+ virtual void canvas_light_set_color(RID p_light, const Color& p_color);
+ virtual void canvas_light_set_height(RID p_light, float p_height);
+ virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z);
+ virtual void canvas_light_set_item_mask(RID p_light, int p_mask);
+
+ enum CanvasightBlendMode {
+ CANVAS_LIGHT_BLEND_ADD,
+ CANVAS_LIGHT_BLEND_SUB,
+ CANVAS_LIGHT_BLEND_MULTIPLY,
+ CANVAS_LIGHT_BLEND_DODGE,
+ CANVAS_LIGHT_BLEND_BURN,
+ CANVAS_LIGHT_BLEND_LIGHTEN,
+ CANVAS_LIGHT_BLEND_DARKEN,
+ CANVAS_LIGHT_BLEND_OVERLAY,
+ CANVAS_LIGHT_BLEND_SCREEN,
+ };
+ virtual void canvas_light_set_blend_mode(RID p_light, CanvasLightBlendMode p_blend_mode);
+ virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled);
+ virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size);
+ virtual void canvas_light_set_shadow_filter(RID p_light, int p_size);
+
+
+ virtual RID canvas_light_occluder_create();
+ virtual void canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas);
+ virtual void canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled);
+ virtual void canvas_light_occluder_set_shape(RID p_occluder,const DVector<Vector2>& p_shape);
+
virtual void canvas_item_clear(RID p_item);
virtual void canvas_item_raise(RID p_item);
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index b59fdbc66a..9574dff018 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -1146,6 +1146,29 @@ public:
FUNC1(canvas_item_clear,RID);
FUNC1(canvas_item_raise,RID);
+ /* CANVAS LIGHT */
+ FUNC0R(RID,canvas_light_create);
+ FUNC2(canvas_light_attach_to_canvas,RID,RID);
+ FUNC2(canvas_light_set_enabled,RID,bool);
+ FUNC2(canvas_light_set_transform,RID,const Matrix32&);
+ FUNC2(canvas_light_set_texture,RID,RID);
+ FUNC2(canvas_light_set_texture_offset,RID,const Vector2&);
+ FUNC2(canvas_light_set_color,RID,const Color&);
+ FUNC2(canvas_light_set_height,RID,float);
+ FUNC3(canvas_light_set_z_range,RID,int,int);
+ FUNC2(canvas_light_set_item_mask,RID,int);
+
+ FUNC2(canvas_light_set_blend_mode,RID,CanvasLightBlendMode);
+ FUNC2(canvas_light_set_shadow_enabled,RID,bool);
+ FUNC2(canvas_light_set_shadow_buffer_size,RID,int);
+ FUNC2(canvas_light_set_shadow_filter,RID,int);
+
+ /* CANVAS OCCLUDER */
+
+ FUNC0R(RID,canvas_light_occluder_create);
+ FUNC2(canvas_light_occluder_attach_to_canvas,RID,RID);
+ FUNC2(canvas_light_occluder_set_enabled,RID,bool);
+ FUNC2(canvas_light_occluder_set_shape,RID,const DVector<Vector2>&);
/* CURSOR */
FUNC2(cursor_set_rotation,float , int ); // radians
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 5721e7acf0..49ae8ce4e6 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -999,6 +999,39 @@ public:
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value)=0;
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const=0;
+ virtual RID canvas_light_create()=0;
+ virtual void canvas_light_attach_to_canvas(RID p_light,RID p_canvas)=0;
+ virtual void canvas_light_set_enabled(RID p_light, bool p_enabled)=0;
+ virtual void canvas_light_set_transform(RID p_light, const Matrix32& p_transform)=0;
+ virtual void canvas_light_set_texture(RID p_light, RID p_texture)=0;
+ virtual void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset)=0;
+ virtual void canvas_light_set_color(RID p_light, const Color& p_color)=0;
+ virtual void canvas_light_set_height(RID p_light, float p_height)=0;
+ virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z)=0;
+ virtual void canvas_light_set_item_mask(RID p_light, int p_mask)=0;
+
+ enum CanvasLightBlendMode {
+ CANVAS_LIGHT_BLEND_ADD,
+ CANVAS_LIGHT_BLEND_SUB,
+ CANVAS_LIGHT_BLEND_MULTIPLY,
+ CANVAS_LIGHT_BLEND_DODGE,
+ CANVAS_LIGHT_BLEND_BURN,
+ CANVAS_LIGHT_BLEND_LIGHTEN,
+ CANVAS_LIGHT_BLEND_DARKEN,
+ CANVAS_LIGHT_BLEND_OVERLAY,
+ CANVAS_LIGHT_BLEND_SCREEN,
+ };
+ virtual void canvas_light_set_blend_mode(RID p_light, CanvasLightBlendMode p_blend_mode)=0;
+ virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled)=0;
+ virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size)=0;
+ virtual void canvas_light_set_shadow_filter(RID p_light, int p_size)=0;
+
+
+ virtual RID canvas_light_occluder_create()=0;
+ virtual void canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas)=0;
+ virtual void canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled)=0;
+ virtual void canvas_light_occluder_set_shape(RID p_occluder,const DVector<Vector2>& p_shape)=0;
+
/* CURSOR */
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0)=0; // radians
virtual void cursor_set_texture(RID p_texture, const Point2 &p_center_offset = Point2(0, 0), int p_cursor=0)=0;