diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-05-04 13:24:02 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-05-04 13:24:02 -0300 |
commit | fbbe7dcdfbd09fc6ef5614dea2183481a27e4f4e (patch) | |
tree | 4e783f0e4347a2f612e6b85398c83a492d7b090f /servers/visual/visual_server_raster.cpp | |
parent | 7f5b744b92256e42aa3c700ee88d8318732935c6 (diff) | |
parent | 6f8bd899311d459b9e391b4acf72ccfa5cc1d806 (diff) |
Merge remote-tracking branch 'origin/master'
Conflicts:
drivers/windows/dir_access_windows.cpp
Diffstat (limited to 'servers/visual/visual_server_raster.cpp')
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 83bfbbc6c3..6556f8bc42 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -3977,6 +3977,15 @@ void VisualServerRaster::canvas_light_set_height(RID p_light, float p_height){ clight->height=p_height; } + +void VisualServerRaster::canvas_light_set_energy(RID p_light, float p_energy){ + + Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); + ERR_FAIL_COND(!clight); + clight->energy=p_energy; + +} + 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); @@ -4012,12 +4021,12 @@ void VisualServerRaster::canvas_light_set_item_shadow_mask(RID p_light, int p_ma } -void VisualServerRaster::canvas_light_set_subtract_mode(RID p_light, bool p_enable) { +void VisualServerRaster::canvas_light_set_mode(RID p_light, CanvasLightMode p_mode) { Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light); ERR_FAIL_COND(!clight); - clight->subtract=p_enable; + clight->mode=p_mode; } void VisualServerRaster::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled){ @@ -4267,12 +4276,12 @@ Variant VisualServerRaster::canvas_item_material_get_shader_param(RID p_material return material->shader_param[p_param]; } -void VisualServerRaster::canvas_item_material_set_unshaded(RID p_material, bool p_unshaded){ +void VisualServerRaster::canvas_item_material_set_shading_mode(RID p_material, CanvasItemShadingMode p_mode) { VS_CHANGED; Rasterizer::CanvasItemMaterial *material = canvas_item_material_owner.get( p_material ); ERR_FAIL_COND(!material); - material->unshaded=p_unshaded; + material->shading_mode=p_mode; } @@ -4384,7 +4393,7 @@ void VisualServerRaster::free( RID p_rid ) { VS_CHANGED; - if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid)) { + if (rasterizer->is_texture(p_rid) || rasterizer->is_material(p_rid) || rasterizer->is_shader(p_rid) || rasterizer->is_environment(p_rid)) { rasterizer->free(p_rid); } else if (rasterizer->is_skeleton(p_rid)) { @@ -4401,7 +4410,7 @@ void VisualServerRaster::free( RID p_rid ) { } rasterizer->free(p_rid); - } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) ) { + } else if (rasterizer->is_mesh(p_rid) || rasterizer->is_multimesh(p_rid) || rasterizer->is_light(p_rid) || rasterizer->is_particles(p_rid) || rasterizer->is_immediate(p_rid)) { //delete the resource _free_attached_instances(p_rid); @@ -6830,6 +6839,7 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat ci->final_transform=xform; ci->final_opacity=opacity * ci->self_opacity; ci->global_rect_cache=global_rect; + ci->global_rect_cache.pos-=p_clip_rect.pos; int zidx = p_z-CANVAS_ITEM_Z_MIN; @@ -7037,17 +7047,20 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ for(Set<Rasterizer::CanvasLight*>::Element *F=E->get().canvas->lights.front();F;F=F->next()) { + Rasterizer::CanvasLight* cl=F->get(); if (cl->enabled && cl->texture.is_valid()) { //not super efficient.. Size2 tsize(rasterizer->texture_get_width(cl->texture),rasterizer->texture_get_height(cl->texture)); tsize*=cl->scale; + Vector2 offset=tsize/2.0; cl->rect_cache=Rect2(-offset+cl->texture_offset,tsize); cl->xform_cache=xf * cl->xform; if (clip_rect.intersects_transformed(cl->xform_cache,cl->rect_cache)) { + cl->filter_next_ptr=lights; lights=cl; cl->texture_cache=NULL; @@ -7057,6 +7070,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse(); cl->light_shader_pos=cl->xform_cache[2]; if (cl->shadow_buffer.is_valid()) { + cl->shadows_next_ptr=lights_with_shadow; if (lights_with_shadow==NULL) { shadow_rect = cl->xform_cache.xform(cl->rect_cache); @@ -7155,7 +7169,7 @@ void VisualServerRaster::_draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ } - //rasterizer->canvas_debug_viewport_shadows(lights_with_shadow); +// rasterizer->canvas_debug_viewport_shadows(lights_with_shadow); } //capture @@ -7382,7 +7396,7 @@ void VisualServerRaster::set_default_clear_color(const Color& p_color) { clear_color=p_color; } -void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color) { +void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_color,bool p_scale) { if (p_image.empty()) return; @@ -7404,9 +7418,27 @@ void VisualServerRaster::set_boot_image(const Image& p_image, const Color& p_col texture_set_data(texture,p_image); rasterizer->canvas_begin_rect(Matrix32()); Rect2 imgrect(0,0,p_image.get_width(),p_image.get_height()); - Rect2 screenrect=imgrect; - screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor(); - rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,0)); + Rect2 screenrect; + if (p_scale) { + + if (window_w > window_h) { + //scale horizontally + screenrect.size.y = window_h; + screenrect.size.x = imgrect.size.x * window_h / imgrect.size.y; + screenrect.pos.x = (window_w - screenrect.size.x)/2; + + } else { + //scale vertically + screenrect.size.x = window_w; + screenrect.size.y = imgrect.size.y * window_w / imgrect.size.x; + screenrect.pos.y = (window_h - screenrect.size.y)/2; + } + } else { + + screenrect=imgrect; + screenrect.pos+=((Size2(vr.width,vr.height)-screenrect.size)/2.0).floor(); + + } rasterizer->canvas_draw_rect(screenrect,0,imgrect,texture,Color(1,1,1,1)); rasterizer->canvas_end_rect(); @@ -7461,6 +7493,10 @@ void VisualServerRaster::finish() { free(default_cursor_texture); + if (test_cube.is_valid()) + free(test_cube); + + _free_internal_rids(); _clean_up_owner( &room_owner,"Room" ); _clean_up_owner( &portal_owner,"Portal" ); @@ -7478,7 +7514,7 @@ void VisualServerRaster::finish() { octree_allocator.clear(); if (instance_dependency_map.size()) { - print_line("base resources missing "+itos(instance_dependency_map.size())); + print_line("Base resources missing amount: "+itos(instance_dependency_map.size())); } ERR_FAIL_COND( instance_dependency_map.size() ); } |