2017-03-05 22:47:28 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* visual_server_viewport.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 06:11:42 +08:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2017-03-05 22:47:28 +08:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2016-10-04 03:33:42 +08:00
|
|
|
#include "visual_server_viewport.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "global_config.h"
|
2016-10-04 03:33:42 +08:00
|
|
|
#include "visual_server_canvas.h"
|
2017-03-05 23:44:50 +08:00
|
|
|
#include "visual_server_global.h"
|
2016-10-19 22:14:41 +08:00
|
|
|
#include "visual_server_scene.h"
|
|
|
|
|
2016-10-04 03:33:42 +08:00
|
|
|
void VisualServerViewport::_draw_viewport(Viewport *p_viewport) {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
/* Camera should always be BEFORE any other 3D */
|
2016-10-04 03:33:42 +08:00
|
|
|
#if 0
|
|
|
|
bool scenario_draw_canvas_bg=false;
|
|
|
|
int scenario_canvas_max_layer=0;
|
|
|
|
|
|
|
|
if (!p_viewport->hide_canvas && !p_viewport->disable_environment && scenario_owner.owns(p_viewport->scenario)) {
|
|
|
|
|
|
|
|
Scenario *scenario=scenario_owner.get(p_viewport->scenario);
|
|
|
|
if (scenario->environment.is_valid()) {
|
|
|
|
if (rasterizer->is_environment(scenario->environment)) {
|
|
|
|
scenario_draw_canvas_bg=rasterizer->environment_get_background(scenario->environment)==VS::ENV_BG_CANVAS;
|
|
|
|
scenario_canvas_max_layer=rasterizer->environment_get_background_param(scenario->environment,VS::ENV_BG_PARAM_CANVAS_MAX_LAYER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool can_draw_3d=!p_viewport->hide_scenario && camera_owner.owns(p_viewport->camera) && scenario_owner.owns(p_viewport->scenario);
|
|
|
|
|
|
|
|
|
|
|
|
if (scenario_draw_canvas_bg) {
|
|
|
|
|
|
|
|
rasterizer->begin_canvas_bg();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!scenario_draw_canvas_bg && can_draw_3d) {
|
|
|
|
|
|
|
|
_draw_viewport_camera(p_viewport,false);
|
|
|
|
|
|
|
|
} else if (true /*|| !p_viewport->canvas_list.empty()*/){
|
|
|
|
|
|
|
|
//clear the viewport black because of no camera? i seriously should..
|
|
|
|
if (p_viewport->render_target_clear_on_new_frame || p_viewport->render_target_clear) {
|
|
|
|
if (p_viewport->transparent_bg) {
|
|
|
|
rasterizer->clear_viewport(Color(0,0,0,0));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Color cc=clear_color;
|
|
|
|
if (scenario_draw_canvas_bg)
|
|
|
|
cc.a=0;
|
|
|
|
rasterizer->clear_viewport(cc);
|
|
|
|
}
|
|
|
|
p_viewport->render_target_clear=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) {
|
2016-10-05 12:26:35 +08:00
|
|
|
VSG::rasterizer->clear_render_target(clear_color);
|
2017-03-05 23:44:50 +08:00
|
|
|
if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
|
|
|
|
p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER;
|
2016-10-05 12:26:35 +08:00
|
|
|
}
|
|
|
|
}
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-06-09 11:23:50 +08:00
|
|
|
if (!p_viewport->disable_3d && !p_viewport->disable_3d_by_usage && p_viewport->camera.is_valid()) {
|
2016-10-19 22:14:41 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::scene->render_camera(p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
|
2016-10-19 22:14:41 +08:00
|
|
|
}
|
|
|
|
|
2016-10-04 03:33:42 +08:00
|
|
|
if (!p_viewport->hide_canvas) {
|
2017-03-05 23:44:50 +08:00
|
|
|
int i = 0;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Map<Viewport::CanvasKey, Viewport::CanvasData *> canvas_map;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Rect2 clip_rect(0, 0, p_viewport->size.x, p_viewport->size.y);
|
|
|
|
RasterizerCanvas::Light *lights = NULL;
|
|
|
|
RasterizerCanvas::Light *lights_with_shadow = NULL;
|
|
|
|
RasterizerCanvas::Light *lights_with_mask = NULL;
|
2016-10-04 03:33:42 +08:00
|
|
|
Rect2 shadow_rect;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
int light_count = 0;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-01-11 11:52:51 +08:00
|
|
|
Transform2D xf = p_viewport->global_transform * E->get().transform;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
//find lights in canvas
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (Set<RasterizerCanvas::Light *>::Element *F = canvas->lights.front(); F; F = F->next()) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
RasterizerCanvas::Light *cl = F->get();
|
2016-10-04 03:33:42 +08:00
|
|
|
if (cl->enabled && cl->texture.is_valid()) {
|
|
|
|
//not super efficient..
|
2017-03-05 23:44:50 +08:00
|
|
|
Size2 tsize(VSG::storage->texture_get_width(cl->texture), VSG::storage->texture_get_height(cl->texture));
|
|
|
|
tsize *= cl->scale;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Vector2 offset = tsize / 2.0;
|
|
|
|
cl->rect_cache = Rect2(-offset + cl->texture_offset, tsize);
|
|
|
|
cl->xform_cache = xf * cl->xform;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (clip_rect.intersects_transformed(cl->xform_cache, cl->rect_cache)) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
cl->filter_next_ptr = lights;
|
|
|
|
lights = cl;
|
|
|
|
cl->texture_cache = NULL;
|
2017-01-11 11:52:51 +08:00
|
|
|
Transform2D scale;
|
2016-10-04 03:33:42 +08:00
|
|
|
scale.scale(cl->rect_cache.size);
|
2017-06-04 06:25:13 +08:00
|
|
|
scale.elements[2] = cl->rect_cache.position;
|
2016-10-04 03:33:42 +08:00
|
|
|
cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse();
|
2017-03-05 23:44:50 +08:00
|
|
|
cl->light_shader_pos = cl->xform_cache[2];
|
2016-10-04 03:33:42 +08:00
|
|
|
if (cl->shadow_buffer.is_valid()) {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
cl->shadows_next_ptr = lights_with_shadow;
|
|
|
|
if (lights_with_shadow == NULL) {
|
2016-10-04 03:33:42 +08:00
|
|
|
shadow_rect = cl->xform_cache.xform(cl->rect_cache);
|
|
|
|
} else {
|
2017-03-05 23:44:50 +08:00
|
|
|
shadow_rect = shadow_rect.merge(cl->xform_cache.xform(cl->rect_cache));
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
lights_with_shadow = cl;
|
|
|
|
cl->radius_cache = cl->rect_cache.size.length();
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
if (cl->mode == VS::CANVAS_LIGHT_MODE_MASK) {
|
|
|
|
cl->mask_next_ptr = lights_with_mask;
|
|
|
|
lights_with_mask = cl;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
light_count++;
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::canvas_render->light_internal_update(cl->light_internal, cl);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//print_line("lights: "+itos(light_count));
|
2017-03-05 23:44:50 +08:00
|
|
|
canvas_map[Viewport::CanvasKey(E->key(), E->get().layer)] = &E->get();
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (lights_with_shadow) {
|
|
|
|
//update shadows if any
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
RasterizerCanvas::LightOccluderInstance *occluders = NULL;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
//make list of occluders
|
2017-03-05 23:44:50 +08:00
|
|
|
for (Map<RID, Viewport::CanvasData>::Element *E = p_viewport->canvas_map.front(); E; E = E->next()) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get().canvas);
|
2017-01-11 11:52:51 +08:00
|
|
|
Transform2D xf = p_viewport->global_transform * E->get().transform;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (Set<RasterizerCanvas::LightOccluderInstance *>::Element *F = canvas->occluders.front(); F; F = F->next()) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
if (!F->get()->enabled)
|
|
|
|
continue;
|
|
|
|
F->get()->xform_cache = xf * F->get()->xform;
|
2017-03-05 23:44:50 +08:00
|
|
|
if (shadow_rect.intersects_transformed(F->get()->xform_cache, F->get()->aabb_cache)) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
F->get()->next = occluders;
|
|
|
|
occluders = F->get();
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//update the light shadowmaps with them
|
2017-03-05 23:44:50 +08:00
|
|
|
RasterizerCanvas::Light *light = lights_with_shadow;
|
|
|
|
while (light) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::canvas_render->canvas_light_shadow_buffer_update(light->shadow_buffer, light->xform_cache.affine_inverse(), light->item_mask, light->radius_cache / 1000.0, light->radius_cache * 1.1, occluders, &light->shadow_matrix_cache);
|
|
|
|
light = light->shadows_next_ptr;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-01-14 19:26:56 +08:00
|
|
|
//VSG::canvas_render->reset_canvas();
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2016-10-05 12:26:35 +08:00
|
|
|
VSG::rasterizer->restore_render_target();
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().layer>scenario_canvas_max_layer) {
|
|
|
|
|
|
|
|
_draw_viewport_camera(p_viewport,!can_draw_3d);
|
|
|
|
scenario_draw_canvas_bg=false;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
2016-10-05 12:26:35 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (Map<Viewport::CanvasKey, Viewport::CanvasData *>::Element *E = canvas_map.front(); E; E = E->next()) {
|
2016-10-05 12:26:35 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas *>(E->get()->canvas);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-01-14 19:26:56 +08:00
|
|
|
//print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size()));
|
2016-10-04 03:33:42 +08:00
|
|
|
//print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform);
|
2017-01-11 11:52:51 +08:00
|
|
|
Transform2D xform = p_viewport->global_transform * E->get()->transform;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
RasterizerCanvas::Light *canvas_lights = NULL;
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
RasterizerCanvas::Light *ptr = lights;
|
|
|
|
while (ptr) {
|
|
|
|
if (E->get()->layer >= ptr->layer_min && E->get()->layer <= ptr->layer_max) {
|
|
|
|
ptr->next_ptr = canvas_lights;
|
|
|
|
canvas_lights = ptr;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
ptr = ptr->filter_next_ptr;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect);
|
2016-10-04 03:33:42 +08:00
|
|
|
i++;
|
|
|
|
#if 0
|
|
|
|
if (scenario_draw_canvas_bg && E->key().layer>=scenario_canvas_max_layer) {
|
|
|
|
_draw_viewport_camera(p_viewport,!can_draw_3d);
|
|
|
|
scenario_draw_canvas_bg=false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
if (scenario_draw_canvas_bg) {
|
|
|
|
_draw_viewport_camera(p_viewport,!can_draw_3d);
|
|
|
|
scenario_draw_canvas_bg=false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//VSG::canvas_render->canvas_debug_viewport_shadows(lights_with_shadow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualServerViewport::draw_viewports() {
|
|
|
|
|
|
|
|
//sort viewports
|
|
|
|
|
|
|
|
//draw viewports
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
clear_color = GLOBAL_GET("rendering/viewport/default_clear_color");
|
2016-10-05 12:26:35 +08:00
|
|
|
|
|
|
|
active_viewports.sort_custom<ViewportSort>();
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
for (int i = 0; i < active_viewports.size(); i++) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
Viewport *vp = active_viewports[i];
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (vp->update_mode == VS::VIEWPORT_UPDATE_DISABLED)
|
2016-10-04 03:33:42 +08:00
|
|
|
continue;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
ERR_CONTINUE(!vp->render_target.is_valid());
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-06-17 19:58:57 +08:00
|
|
|
bool visible = vp->viewport_to_screen_rect != Rect2() || vp->update_mode == VS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == VS::VIEWPORT_UPDATE_ONCE || (vp->update_mode == VS::VIEWPORT_UPDATE_WHEN_VISIBLE && VSG::storage->render_target_was_used(vp->render_target));
|
2016-10-19 22:14:41 +08:00
|
|
|
|
|
|
|
if (!visible)
|
|
|
|
continue;
|
|
|
|
|
2017-06-17 19:58:57 +08:00
|
|
|
VSG::storage->render_target_clear_used(vp->render_target);
|
|
|
|
|
2016-10-04 03:33:42 +08:00
|
|
|
VSG::rasterizer->set_current_render_target(vp->render_target);
|
2017-06-12 02:52:03 +08:00
|
|
|
|
|
|
|
VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
|
2017-06-12 05:13:04 +08:00
|
|
|
VSG::storage->render_info_begin_capture();
|
2017-06-12 02:52:03 +08:00
|
|
|
|
2016-10-04 03:33:42 +08:00
|
|
|
_draw_viewport(vp);
|
|
|
|
|
2017-06-12 05:13:04 +08:00
|
|
|
VSG::storage->render_info_end_capture();
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_OBJECTS_IN_FRAME);
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_VERTICES_IN_FRAME);
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_MATERIAL_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_MATERIAL_CHANGES_IN_FRAME);
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_SHADER_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SHADER_CHANGES_IN_FRAME);
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_SURFACE_CHANGES_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_SURFACE_CHANGES_IN_FRAME);
|
|
|
|
vp->render_info[VS::VIEWPORT_RENDER_INFO_DRAW_CALLS_IN_FRAME] = VSG::storage->get_captured_render_info(VS::INFO_DRAW_CALLS_IN_FRAME);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (vp->viewport_to_screen_rect != Rect2()) {
|
2016-10-04 03:33:42 +08:00
|
|
|
//copy to screen if set as such
|
|
|
|
VSG::rasterizer->set_current_render_target(RID());
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::rasterizer->blit_render_target_to_screen(vp->render_target, vp->viewport_to_screen_rect, vp->viewport_to_screen);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) {
|
|
|
|
vp->update_mode = VS::VIEWPORT_UPDATE_DISABLED;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-06-12 02:52:03 +08:00
|
|
|
VSG::scene_render->set_debug_draw_mode(VS::VIEWPORT_DEBUG_DRAW_DISABLED);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RID VisualServerViewport::viewport_create() {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = memnew(Viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
RID rid = viewport_owner.make_rid(viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->self = rid;
|
|
|
|
viewport->hide_scenario = false;
|
|
|
|
viewport->hide_canvas = false;
|
|
|
|
viewport->render_target = VSG::storage->render_target_create();
|
|
|
|
viewport->shadow_atlas = VSG::scene_render->shadow_atlas_create();
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
return rid;
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
ERR_FAIL_COND(p_width < 0 && p_height < 0);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->size = Size2(p_width, p_height);
|
|
|
|
VSG::storage->render_target_set_size(viewport->render_target, p_width, p_height);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_active(RID p_viewport, bool p_active) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
if (p_active) {
|
2017-03-05 23:44:50 +08:00
|
|
|
ERR_FAIL_COND(active_viewports.find(viewport) != -1); //already active
|
2016-10-04 03:33:42 +08:00
|
|
|
active_viewports.push_back(viewport);
|
|
|
|
} else {
|
|
|
|
active_viewports.erase(viewport);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) {
|
2016-10-05 12:26:35 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-05 12:26:35 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->parent = p_parent_viewport;
|
2016-10-05 12:26:35 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_clear_mode(RID p_viewport, VS::ViewportClearMode p_clear_mode) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->clear_mode = p_clear_mode;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_rect, int p_screen) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->viewport_to_screen_rect = p_rect;
|
|
|
|
viewport->viewport_to_screen = p_screen;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_detach(RID p_viewport) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->viewport_to_screen_rect = Rect2();
|
|
|
|
viewport->viewport_to_screen = 0;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_update_mode(RID p_viewport, VS::ViewportUpdateMode p_mode) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->update_mode = p_mode;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_vflip(RID p_viewport, bool p_enable) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_VFLIP, p_enable);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
RID VisualServerViewport::viewport_get_texture(RID p_viewport) const {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
const Viewport *viewport = viewport_owner.getornull(p_viewport);
|
|
|
|
ERR_FAIL_COND_V(!viewport, RID());
|
2016-10-04 03:33:42 +08:00
|
|
|
|
|
|
|
return VSG::storage->render_target_get_texture(viewport->render_target);
|
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_hide_scenario(RID p_viewport, bool p_hide) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->hide_scenario = p_hide;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_hide_canvas(RID p_viewport, bool p_hide) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->hide_canvas = p_hide;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_disable_environment(RID p_viewport, bool p_disable) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->disable_environment = p_disable;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_disable_3d(RID p_viewport, bool p_disable) {
|
2016-10-05 12:26:35 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-05 12:26:35 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->disable_3d = p_disable;
|
2017-06-09 11:23:50 +08:00
|
|
|
//VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, p_disable);
|
|
|
|
//this should be just for disabling rendering of 3D, to actually disable it, set usage
|
2016-10-05 12:26:35 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_attach_camera(RID p_viewport, RID p_camera) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->camera = p_camera;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_scenario(RID p_viewport, RID p_scenario) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->scenario = p_scenario;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_attach_canvas(RID p_viewport, RID p_canvas) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
ERR_FAIL_COND(viewport->canvas_map.has(p_canvas));
|
|
|
|
VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas);
|
|
|
|
ERR_FAIL_COND(!canvas);
|
|
|
|
|
|
|
|
canvas->viewports.insert(p_viewport);
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->canvas_map[p_canvas] = Viewport::CanvasData();
|
|
|
|
viewport->canvas_map[p_canvas].layer = 0;
|
|
|
|
viewport->canvas_map[p_canvas].canvas = canvas;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_remove_canvas(RID p_viewport, RID p_canvas) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
VisualServerCanvas::Canvas *canvas = VSG::canvas->canvas_owner.getornull(p_canvas);
|
|
|
|
ERR_FAIL_COND(!canvas);
|
|
|
|
|
|
|
|
viewport->canvas_map.erase(p_canvas);
|
|
|
|
canvas->viewports.erase(p_viewport);
|
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport, RID p_canvas, const Transform2D &p_offset) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->canvas_map[p_canvas].transform = p_offset;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_transparent_background(RID p_viewport, bool p_enabled) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_TRANSPARENT, p_enabled);
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport, const Transform2D &p_transform) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->global_transform = p_transform;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_canvas_layer(RID p_viewport, RID p_canvas, int p_layer) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
ERR_FAIL_COND(!viewport->canvas_map.has(p_canvas));
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->canvas_map[p_canvas].layer = p_layer;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_shadow_atlas_size(RID p_viewport, int p_size) {
|
2016-11-10 10:55:06 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-11-10 10:55:06 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport->shadow_atlas_size = p_size;
|
2016-11-10 10:55:06 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::scene_render->shadow_atlas_set_size(viewport->shadow_atlas, viewport->shadow_atlas_size);
|
2016-11-10 10:55:06 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_shadow_atlas_quadrant_subdivision(RID p_viewport, int p_quadrant, int p_subdiv) {
|
2016-11-10 10:55:06 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2016-11-10 10:55:06 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::scene_render->shadow_atlas_set_quadrant_subdivision(viewport->shadow_atlas, p_quadrant, p_subdiv);
|
2016-11-10 10:55:06 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_msaa) {
|
2017-01-02 09:16:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2017-01-02 09:16:52 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::storage->render_target_set_msaa(viewport->render_target, p_msaa);
|
2017-01-02 09:16:52 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_hdr(RID p_viewport, bool p_enabled) {
|
2017-01-02 09:16:52 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2017-01-02 09:16:52 +08:00
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_HDR, p_enabled);
|
2017-01-02 09:16:52 +08:00
|
|
|
}
|
2016-11-10 10:55:06 +08:00
|
|
|
|
2017-06-09 11:23:50 +08:00
|
|
|
void VisualServerViewport::viewport_set_usage(RID p_viewport, VS::ViewportUsage p_usage) {
|
|
|
|
|
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
switch (p_usage) {
|
|
|
|
case VS::VIEWPORT_USAGE_2D: {
|
|
|
|
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, true);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS, true);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_SAMPLING, false);
|
|
|
|
|
|
|
|
viewport->disable_3d_by_usage = true;
|
|
|
|
} break;
|
|
|
|
case VS::VIEWPORT_USAGE_2D_NO_SAMPLING: {
|
|
|
|
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, true);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS, true);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_SAMPLING, true);
|
|
|
|
viewport->disable_3d_by_usage = true;
|
|
|
|
} break;
|
|
|
|
case VS::VIEWPORT_USAGE_3D: {
|
|
|
|
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, false);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS, false);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_SAMPLING, false);
|
|
|
|
viewport->disable_3d_by_usage = false;
|
|
|
|
} break;
|
|
|
|
case VS::VIEWPORT_USAGE_3D_NO_EFFECTS: {
|
|
|
|
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D, false);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_3D_EFFECTS, true);
|
|
|
|
VSG::storage->render_target_set_flag(viewport->render_target, RasterizerStorage::RENDER_TARGET_NO_SAMPLING, false);
|
|
|
|
viewport->disable_3d_by_usage = false;
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 02:52:03 +08:00
|
|
|
int VisualServerViewport::viewport_get_render_info(RID p_viewport, VS::ViewportRenderInfo p_info) {
|
|
|
|
|
|
|
|
ERR_FAIL_INDEX_V(p_info, VS::VIEWPORT_RENDER_INFO_MAX, -1);
|
2017-06-12 05:13:04 +08:00
|
|
|
|
2017-06-12 02:52:03 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
2017-06-12 05:13:04 +08:00
|
|
|
if (!viewport)
|
|
|
|
return 0; //there should be a lock here..
|
2017-06-12 02:52:03 +08:00
|
|
|
|
|
|
|
return viewport->render_info[p_info];
|
|
|
|
}
|
|
|
|
|
|
|
|
void VisualServerViewport::viewport_set_debug_draw(RID p_viewport, VS::ViewportDebugDraw p_draw) {
|
|
|
|
|
|
|
|
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
|
|
|
ERR_FAIL_COND(!viewport);
|
|
|
|
|
|
|
|
viewport->debug_draw = p_draw;
|
|
|
|
}
|
|
|
|
|
2016-10-04 03:33:42 +08:00
|
|
|
bool VisualServerViewport::free(RID p_rid) {
|
|
|
|
|
2016-11-20 00:23:37 +08:00
|
|
|
if (viewport_owner.owns(p_rid)) {
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Viewport *viewport = viewport_owner.getornull(p_rid);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VSG::storage->free(viewport->render_target);
|
|
|
|
VSG::scene_render->free(viewport->shadow_atlas);
|
2016-11-20 00:23:37 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
while (viewport->canvas_map.front()) {
|
|
|
|
viewport_remove_canvas(p_rid, viewport->canvas_map.front()->key());
|
2016-11-20 00:23:37 +08:00
|
|
|
}
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
viewport_set_scenario(p_rid, RID());
|
2016-11-20 00:23:37 +08:00
|
|
|
active_viewports.erase(viewport);
|
|
|
|
|
|
|
|
viewport_owner.free(p_rid);
|
|
|
|
memdelete(viewport);
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2016-11-20 00:23:37 +08:00
|
|
|
return true;
|
|
|
|
}
|
2016-10-04 03:33:42 +08:00
|
|
|
|
2016-11-20 00:23:37 +08:00
|
|
|
return false;
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
VisualServerViewport::VisualServerViewport() {
|
2016-10-04 03:33:42 +08:00
|
|
|
}
|