Blender V5.3
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 = id_cast<Camera *>(ob->data);
42 if (cam == nullptr || cam->type != CAM_CUSTOM) {
43 return false;
44 }
45
46 if (cam->custom_mode == CAM_CUSTOM_SHADER_EXTERNAL) {
47 return cam->custom_filepath[0] != '\0';
48 }
49 return cam->custom_shader != nullptr;
50}
51
53{
56 Camera *cam = id_cast<Camera *>(ob->data);
57
58 /* setup render engine */
59 RenderEngine *engine = RE_engine_create(type);
60 engine->reports = op->reports;
61
62 type->update_custom_camera(engine, cam);
63
64 RE_engine_free(engine);
65
66 return OPERATOR_FINISHED;
67}
68
70{
71 /* identifiers */
72 ot->name = "Custom Camera Update";
73 ot->description = "Update custom camera with new parameters from the shader";
74 ot->idname = "OBJECT_OT_camera_custom_update";
75
76 /* API callbacks. */
79
80 /* flags */
82}
83
85
86} // namespace blender::ed::object
#define C
Definition RandGen.cpp:29
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)
@ CAM_CUSTOM_SHADER_EXTERNAL
RenderEngineType * CTX_data_engine_type(const bContext *C)
void RE_engine_free(RenderEngine *engine)
RenderEngine * RE_engine_create(RenderEngineType *type)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void(*) update_custom_camera(struct RenderEngine *engine, struct Camera *cam)
Definition RE_engine.h:126
struct ReportList * reports
Definition RE_engine.h:154
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
struct ReportList * reports