Blender V5.0
object_camera.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "object_intern.hh"
10
11#include "DNA_camera_types.h"
12
13#include "BKE_context.hh"
14
15#include "ED_object.hh"
16
17#include "RE_engine.h"
18
19#include "WM_api.hh"
20
21namespace blender::ed::object {
22
23/* -------------------------------------------------------------------- */
26
28{
31
32 /* Test if we have a render engine that supports custom cameras. */
33 if (!(type && type->update_custom_camera)) {
34 return false;
35 }
36
37 /* See if we have a custom camera in context. */
38 if (ob == nullptr || ob->type != OB_CAMERA) {
39 return false;
40 }
41 Camera *cam = static_cast<Camera *>(ob->data);
42 if (cam == nullptr || cam->type != CAM_CUSTOM) {
43 return false;
44 }
45
47 return cam->custom_filepath[0] != '\0';
48 }
49 else {
50 return cam->custom_shader != nullptr;
51 }
52}
53
55{
58 Camera *cam = static_cast<Camera *>(ob->data);
59
60 /* setup render engine */
61 RenderEngine *engine = RE_engine_create(type);
62 engine->reports = op->reports;
63
64 type->update_custom_camera(engine, cam);
65
66 RE_engine_free(engine);
67
68 return OPERATOR_FINISHED;
69}
70
72{
73 /* identifiers */
74 ot->name = "Custom Camera Update";
75 ot->description = "Update custom camera with new parameters from the shader";
76 ot->idname = "OBJECT_OT_camera_custom_update";
77
78 /* API callbacks. */
81
82 /* flags */
84}
85
87
88} // namespace blender::ed::object
RenderEngineType * CTX_data_engine_type(const bContext *C)
@ CAM_CUSTOM_SHADER_EXTERNAL
@ CAM_CUSTOM
@ OB_CAMERA
@ OPERATOR_FINISHED
#define C
Definition RandGen.cpp:29
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
RenderEngine * RE_engine_create(RenderEngineType *type)
void RE_engine_free(RenderEngine *engine)
static bool object_camera_custom_update_poll(bContext *C)
static wmOperatorStatus object_camera_custom_update_exec(bContext *C, wmOperator *op)
Object * context_active_object(const bContext *C)
void OBJECT_OT_camera_custom_update(wmOperatorType *ot)
struct Text * custom_shader
char custom_filepath[1024]
void(* update_custom_camera)(struct RenderEngine *engine, struct Camera *cam)
Definition RE_engine.h:113
struct ReportList * reports
Definition RE_engine.h:143
struct ReportList * reports
wmOperatorType * ot
Definition wm_files.cc:4237