Commit: dd5fcd4d0f9e4da98bf6c46d6a87b2ead0709b4c Author: Nick Wu Date: Wed Jul 25 22:25:18 2018 +0800 Branches: soc-2018-npr https://developer.blender.org/rBdd5fcd4d0f9e4da98bf6c46d6a87b2ead0709b4c
Fix camera access error, added report to no camera situation. =================================================================== M source/blender/draw/engines/lanpr/lanpr_dpix.c M source/blender/draw/engines/lanpr/lanpr_engine.c M source/blender/draw/engines/lanpr/lanpr_ops.c =================================================================== diff --git a/source/blender/draw/engines/lanpr/lanpr_dpix.c b/source/blender/draw/engines/lanpr/lanpr_dpix.c index d717b7799fc..db9210b3947 100644 --- a/source/blender/draw/engines/lanpr/lanpr_dpix.c +++ b/source/blender/draw/engines/lanpr/lanpr_dpix.c @@ -42,7 +42,7 @@ void lanpr_init_atlas_inputs(void *ved){ const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; RegionView3D *rv3d = draw_ctx->rv3d; - Object *camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; + Object *camera = (rv3d && rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; SceneLANPR *lanpr = &draw_ctx->scene->lanpr; if (lanpr->reloaded || !txl->dpix_in_pl) { @@ -377,11 +377,12 @@ void lanpr_dpix_draw_scene(LANPR_TextureList *txl, LANPR_FramebufferList *fbl, L Object *camera; if (v3d) { RegionView3D *rv3d = draw_ctx->rv3d; - camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; + camera = (rv3d && rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; } - else { + if(!camera){ camera = scene->camera; } + if (!camera) return; pd->dpix_viewport[2] = texw; pd->dpix_viewport[3] = texh; diff --git a/source/blender/draw/engines/lanpr/lanpr_engine.c b/source/blender/draw/engines/lanpr/lanpr_engine.c index 755801b6585..11b7bbf0d0e 100644 --- a/source/blender/draw/engines/lanpr/lanpr_engine.c +++ b/source/blender/draw/engines/lanpr/lanpr_engine.c @@ -59,14 +59,6 @@ static void lanpr_engine_init(void *ved){ Scene *scene = DEG_get_evaluated_scene(draw_ctx->depsgraph); SceneLANPR *lanpr = &scene->lanpr; View3D *v3d = draw_ctx->v3d; - Object *camera; - if (v3d) { - RegionView3D *rv3d = draw_ctx->rv3d; - camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; - } - else { - camera = scene->camera; - } if (!OneTime.InitComplete) { //lanpr->depth_clamp = 0.01; @@ -269,14 +261,6 @@ static void lanpr_cache_init(void *vedata){ Scene *scene = DEG_get_evaluated_scene(draw_ctx->depsgraph); SceneLANPR *lanpr = &scene->lanpr; View3D *v3d = draw_ctx->v3d; - Object *camera; - if (v3d) { - RegionView3D *rv3d = draw_ctx->rv3d; - camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; - } - else { - camera = scene->camera; - } psl->color_pass = DRW_pass_create("color Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH); stl->g_data->multipass_shgrp = DRW_shgroup_create(OneTime.multichannel_shader, psl->color_pass); @@ -466,14 +450,6 @@ static void lanpr_draw_scene_exec(void *vedata, GPUFrameBuffer *dfb) { Scene *scene = DEG_get_evaluated_scene(draw_ctx->depsgraph); SceneLANPR *lanpr = &scene->lanpr; View3D *v3d = draw_ctx->v3d; - Object *camera; - if (v3d) { - RegionView3D *rv3d = draw_ctx->rv3d; - camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; - } - else { - camera = scene->camera; - } //DEBUG, draw a square only { diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_ops.c index ee594033d95..fef1d451fc7 100644 --- a/source/blender/draw/engines/lanpr/lanpr_ops.c +++ b/source/blender/draw/engines/lanpr/lanpr_ops.c @@ -21,6 +21,7 @@ #include "DEG_depsgraph_query.h" #include "BKE_camera.h" #include "BKE_collection.h" +#include "BKE_report.h" #include "GPU_draw.h" #include "GPU_batch.h" @@ -1687,7 +1688,6 @@ void lanpr_make_render_geometry_buffers(Depsgraph *depsgraph, Scene *s, Object * CollectionObject *co; tnsMatrix44d obmat16; tnsMatrix44d proj, view, result, inv; - if (!c) return; Camera *cam = c->data; float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); @@ -2994,14 +2994,14 @@ void lanpr_software_draw_scene(void *vedata, GPUFrameBuffer *dfb) { Scene *scene = DEG_get_evaluated_scene(draw_ctx->depsgraph); SceneLANPR *lanpr = &scene->lanpr; View3D *v3d = draw_ctx->v3d; - Object *camera; - if (v3d) { - RegionView3D *rv3d = draw_ctx->rv3d; - camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; - } - else { - camera = scene->camera; - } + //Object *camera; + //if (v3d) { + // RegionView3D *rv3d = draw_ctx->rv3d; + // camera = (rv3d->persp == RV3D_CAMOB) ? v3d->camera : NULL; + //} + //else { + // camera = scene->camera; + //} GPU_framebuffer_bind(fbl->software_ms); GPU_framebuffer_clear(fbl->software_ms, clear_bits, lanpr->background_color, clear_depth, clear_stencil); @@ -3107,8 +3107,11 @@ static int lanpr_compute_feature_lines_exec(struct bContext *C, struct wmOperato LANPR_RenderBuffer *rb; Depsgraph *depsgraph = CTX_data_depsgraph(C); - /* need threading, later.... */ - + if (!scene->camera) { + BKE_report(op->reports, RPT_ERROR, "There is no active camera in this scene!"); + return OPERATOR_FINISHED; + } + rb = lanpr_create_render_buffer(lanpr); rb->Scene = scene; rb->W = scene->r.xsch; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs