diff options
author | reduz <juan@okamstudio.com> | 2015-02-16 14:45:11 -0300 |
---|---|---|
committer | reduz <juan@okamstudio.com> | 2015-02-16 14:45:11 -0300 |
commit | 2bea642583efeb68886e71950384f297f2d7ee12 (patch) | |
tree | 4156e1805c34c1358aec26a93c87bbba7e562f5e /servers | |
parent | d7ea20c1664a23bb8606bff85028c01f3b123fde (diff) |
-Some more work on 2D Lights (NOT FUNCTIONAL YET!)
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 33 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 51 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 2 |
3 files changed, 85 insertions, 1 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 fc32702a12..e8fa319f11 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -3823,60 +3823,100 @@ void VisualServerRaster::canvas_item_raise(RID p_item) { RID VisualServerRaster::canvas_light_create() { - return RID(); + 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); } @@ -4186,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 57032ab441..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 { |