diff options
Diffstat (limited to 'servers/visual')
-rw-r--r-- | servers/visual/rasterizer.h | 5 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.cpp | 5 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 53 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 3 | ||||
-rw-r--r-- | servers/visual/visual_server_wrap_mt.h | 3 |
6 files changed, 62 insertions, 10 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 79365f7db6..15c757665b 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -502,7 +502,7 @@ public: virtual void begin_scene(RID p_viewport_data,RID p_env,VS::ScenarioDebugMode p_debug)=0; virtual void begin_shadow_map( RID p_light_instance, int p_shadow_pass )=0; - virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection)=0; + virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection,bool p_ortho_hint)=0; virtual void add_light( RID p_light_instance )=0; ///< all "add_light" calls happen before add_geometry calls @@ -592,6 +592,7 @@ public: RID shadow_buffer; int shadow_buffer_size; float shadow_esm_mult; + Color shadow_color; void *texture_cache; // implementation dependent @@ -610,6 +611,7 @@ public: CanvasLight() { enabled=true; color=Color(1,1,1); + shadow_color=Color(0,0,0,0); height=0; z_min=-1024; z_max=1024; @@ -1020,6 +1022,7 @@ public: virtual bool has_feature(VS::Features p_feature) const=0; + virtual void restore_framebuffer()=0; virtual int get_render_info(VS::RenderInfo p_info)=0; diff --git a/servers/visual/rasterizer_dummy.cpp b/servers/visual/rasterizer_dummy.cpp index 8db1cbf6e5..c05438aef3 100644 --- a/servers/visual/rasterizer_dummy.cpp +++ b/servers/visual/rasterizer_dummy.cpp @@ -1497,7 +1497,7 @@ void RasterizerDummy::begin_shadow_map( RID p_light_instance, int p_shadow_pass } -void RasterizerDummy::set_camera(const Transform& p_world,const CameraMatrix& p_projection) { +void RasterizerDummy::set_camera(const Transform& p_world, const CameraMatrix& p_projection, bool p_ortho_hint) { } @@ -1948,6 +1948,9 @@ bool RasterizerDummy::has_feature(VS::Features p_feature) const { } +void RasterizerDummy::restore_framebuffer() { + +} RasterizerDummy::RasterizerDummy() { diff --git a/servers/visual/rasterizer_dummy.h b/servers/visual/rasterizer_dummy.h index 318cf6ff99..9249ad6256 100644 --- a/servers/visual/rasterizer_dummy.h +++ b/servers/visual/rasterizer_dummy.h @@ -679,7 +679,7 @@ public: virtual void begin_scene(RID p_viewport_data,RID p_env,VS::ScenarioDebugMode p_debug); virtual void begin_shadow_map( RID p_light_instance, int p_shadow_pass ); - virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection); + virtual void set_camera(const Transform& p_world,const CameraMatrix& p_projection,bool p_ortho_hint); virtual void add_light( RID p_light_instance ); ///< all "add_light" calls happen before add_geometry calls @@ -779,6 +779,7 @@ public: virtual bool has_feature(VS::Features p_feature) const; + virtual void restore_framebuffer(); RasterizerDummy(); virtual ~RasterizerDummy(); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 52e5c21272..5b52ca93aa 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -454,6 +454,14 @@ AABB VisualServerRaster::mesh_get_custom_aabb(RID p_mesh) const { return rasterizer->mesh_get_custom_aabb(p_mesh); } +void VisualServerRaster::mesh_clear(RID p_mesh) { + + ERR_FAIL_COND(!rasterizer->is_mesh(p_mesh)); + while(rasterizer->mesh_get_surface_count(p_mesh)) { + rasterizer->mesh_remove_surface(p_mesh,0); + } +} + /* MULTIMESH */ @@ -4071,6 +4079,15 @@ void VisualServerRaster::canvas_light_set_shadow_esm_multiplier(RID p_light, flo } +void VisualServerRaster::canvas_light_set_shadow_color(RID p_light, const Color& p_color) { + + Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); + ERR_FAIL_COND(!clight); + clight->shadow_color=p_color; + +} + + /****** CANVAS LIGHT OCCLUDER ******/ RID VisualServerRaster::canvas_light_occluder_create() { @@ -5202,7 +5219,6 @@ void VisualServerRaster::_light_instance_update_lispsm_shadow(Instance *p_light, AABB proj_space_aabb; - float max_d,min_d; { @@ -6302,7 +6318,7 @@ void VisualServerRaster::_render_no_camera(Viewport *p_viewport,Camera *p_camera else environment=p_scenario->fallback_environment; - rasterizer->set_camera(Transform(),CameraMatrix()); + rasterizer->set_camera(Transform(),CameraMatrix(),false); rasterizer->begin_scene(p_viewport->viewport_data,environment,p_scenario->debug); rasterizer->set_viewport(viewport_rect); rasterizer->end_scene(); @@ -6318,7 +6334,8 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S /* STEP 1 - SETUP CAMERA */ CameraMatrix camera_matrix; - + bool ortho=false; + switch(p_camera->type) { case Camera::ORTHOGONAL: { @@ -6330,6 +6347,7 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S p_camera->vaspect ); + ortho=true; } break; case Camera::PERSPECTIVE: { @@ -6341,12 +6359,13 @@ void VisualServerRaster::_render_camera(Viewport *p_viewport,Camera *p_camera, S p_camera->vaspect ); + ortho=false; } break; } - rasterizer->set_camera(p_camera->transform, camera_matrix); + rasterizer->set_camera(p_camera->transform, camera_matrix,ortho); Vector<Plane> planes = camera_matrix.get_projection_planes(p_camera->transform); @@ -6804,7 +6823,11 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat copymem(child_items,ci->child_items.ptr(),child_item_count*sizeof(CanvasItem*)); if (ci->clip) { - ci->final_clip_rect=global_rect; + if (p_canvas_clip != NULL) { + ci->final_clip_rect=p_canvas_clip->final_clip_rect.clip(global_rect); + } else { + ci->final_clip_rect=global_rect; + } ci->final_clip_owner=ci; } else { @@ -7339,6 +7362,8 @@ void VisualServerRaster::_draw_cursors_and_margins() { rasterizer->canvas_draw_rect(Rect2(cursors[i].pos, size), 0, Rect2(), tex, Color(1, 1, 1, 1)); }; + + if (black_image[MARGIN_LEFT].is_valid()) { Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_LEFT]),rasterizer->texture_get_height(black_image[MARGIN_LEFT])); rasterizer->canvas_draw_rect(Rect2(0,0,black_margin[MARGIN_LEFT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_LEFT],Color(1,1,1)); @@ -7350,10 +7375,22 @@ void VisualServerRaster::_draw_cursors_and_margins() { rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_RIGHT],Color(1,1,1)); } else if (black_margin[MARGIN_RIGHT]) rasterizer->canvas_draw_rect(Rect2(window_w-black_margin[MARGIN_RIGHT],0,black_margin[MARGIN_RIGHT],window_h),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - if (black_margin[MARGIN_TOP]) + + if (black_image[MARGIN_TOP].is_valid()) { + Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_TOP]),rasterizer->texture_get_height(black_image[MARGIN_TOP])); + rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_TOP],Color(1,1,1)); + + } else if (black_margin[MARGIN_TOP]) { rasterizer->canvas_draw_rect(Rect2(0,0,window_w,black_margin[MARGIN_TOP]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); - if (black_margin[MARGIN_BOTTOM]) + } + + if (black_image[MARGIN_BOTTOM].is_valid()) { + + Size2 sz(rasterizer->texture_get_width(black_image[MARGIN_BOTTOM]),rasterizer->texture_get_height(black_image[MARGIN_BOTTOM])); + rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,sz.x,sz.y),black_image[MARGIN_BOTTOM],Color(1,1,1)); + } else if (black_margin[MARGIN_BOTTOM]) { rasterizer->canvas_draw_rect(Rect2(0,window_h-black_margin[MARGIN_BOTTOM],window_w,black_margin[MARGIN_BOTTOM]),0,Rect2(0,0,1,1),RID(),Color(0,0,0)); + } rasterizer->canvas_end_rect(); }; @@ -7401,6 +7438,8 @@ void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_col if (p_image.empty()) return; + rasterizer->restore_framebuffer(); + rasterizer->begin_frame(); int window_w = OS::get_singleton()->get_video_mode(0).width; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index e2940c216b..3d8331984a 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -765,6 +765,7 @@ public: virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb); virtual AABB mesh_get_custom_aabb(RID p_mesh) const; + virtual void mesh_clear(RID p_mesh); /* MULTIMESH API */ @@ -1180,6 +1181,8 @@ public: 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_esm_multiplier(RID p_light, float p_multiplier); + virtual void canvas_light_set_shadow_color(RID p_light, const Color& p_color); + virtual RID canvas_light_occluder_create(); diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 6719342a6a..af88c9bdc9 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -199,6 +199,7 @@ public: FUNC2(mesh_remove_surface,RID,int); FUNC1RC(int,mesh_get_surface_count,RID); + FUNC1(mesh_clear,RID); FUNC2(mesh_set_custom_aabb,RID,const AABB&); @@ -626,6 +627,8 @@ public: FUNC2(canvas_light_set_shadow_enabled,RID,bool); FUNC2(canvas_light_set_shadow_buffer_size,RID,int); FUNC2(canvas_light_set_shadow_esm_multiplier,RID,float); + FUNC2(canvas_light_set_shadow_color,RID,const Color&); + /* CANVAS OCCLUDER */ |