Blender
V4.5
source
blender
editors
object
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
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
21
namespace
blender::ed::object
{
22
23
/* -------------------------------------------------------------------- */
27
static
bool
object_camera_custom_update_poll
(
bContext
*C)
28
{
29
Object
*ob =
context_active_object
(C);
30
RenderEngineType
*type =
CTX_data_engine_type
(C);
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
46
if
(cam->
custom_mode
==
CAM_CUSTOM_SHADER_EXTERNAL
) {
47
return
cam->
custom_filepath
[0] !=
'\0'
;
48
}
49
else
{
50
return
cam->
custom_shader
!=
nullptr
;
51
}
52
}
53
54
static
wmOperatorStatus
object_camera_custom_update_exec
(
bContext
*C,
wmOperator
*op)
55
{
56
Object
*ob =
context_active_object
(C);
57
RenderEngineType
*type =
CTX_data_engine_type
(C);
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
71
void
OBJECT_OT_camera_custom_update
(
wmOperatorType
*
ot
)
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. */
79
ot
->
exec
=
object_camera_custom_update_exec
;
80
ot
->
poll
=
object_camera_custom_update_poll
;
81
82
/* flags */
83
ot
->
flag
=
OPTYPE_REGISTER
|
OPTYPE_UNDO
;
84
}
85
88
}
// namespace blender::ed::object
BKE_context.hh
CTX_data_engine_type
RenderEngineType * CTX_data_engine_type(const bContext *C)
Definition
blenkernel/intern/context.cc:1181
DNA_camera_types.h
CAM_CUSTOM_SHADER_EXTERNAL
@ CAM_CUSTOM_SHADER_EXTERNAL
Definition
DNA_camera_types.h:169
CAM_CUSTOM
@ CAM_CUSTOM
Definition
DNA_camera_types.h:152
OB_CAMERA
@ OB_CAMERA
Definition
DNA_object_types.h:455
wmOperatorStatus
wmOperatorStatus
Definition
DNA_windowmanager_enums.h:16
OPERATOR_FINISHED
@ OPERATOR_FINISHED
Definition
DNA_windowmanager_enums.h:19
ED_object.hh
RE_engine.h
WM_api.hh
OPTYPE_UNDO
@ OPTYPE_UNDO
Definition
WM_types.hh:182
OPTYPE_REGISTER
@ OPTYPE_REGISTER
Definition
WM_types.hh:180
RE_engine_create
RenderEngine * RE_engine_create(RenderEngineType *type)
Definition
intern/engine.cc:127
RE_engine_free
void RE_engine_free(RenderEngine *engine)
Definition
intern/engine.cc:169
blender::ed::object
Definition
ED_object.hh:44
blender::ed::object::object_camera_custom_update_poll
static bool object_camera_custom_update_poll(bContext *C)
Definition
object_camera.cc:27
blender::ed::object::object_camera_custom_update_exec
static wmOperatorStatus object_camera_custom_update_exec(bContext *C, wmOperator *op)
Definition
object_camera.cc:54
blender::ed::object::context_active_object
Object * context_active_object(const bContext *C)
Definition
object_edit.cc:148
blender::ed::object::OBJECT_OT_camera_custom_update
void OBJECT_OT_camera_custom_update(wmOperatorType *ot)
Definition
object_camera.cc:71
object_intern.hh
Camera
Definition
DNA_camera_types.h:73
Camera::custom_shader
struct Text * custom_shader
Definition
DNA_camera_types.h:119
Camera::custom_filepath
char custom_filepath[1024]
Definition
DNA_camera_types.h:121
Camera::type
char type
Definition
DNA_camera_types.h:84
Camera::custom_mode
int custom_mode
Definition
DNA_camera_types.h:125
Object
Definition
DNA_object_types.h:192
Object::type
short type
Definition
DNA_object_types.h:205
Object::data
void * data
Definition
DNA_object_types.h:224
RenderEngineType
Definition
RE_engine.h:70
RenderEngineType::update_custom_camera
void(* update_custom_camera)(struct RenderEngine *engine, struct Camera *cam)
Definition
RE_engine.h:114
RenderEngine
Definition
RE_engine.h:130
RenderEngine::reports
struct ReportList * reports
Definition
RE_engine.h:144
bContext
Definition
blenkernel/intern/context.cc:58
wmOperatorType
Definition
WM_types.hh:1028
wmOperatorType::name
const char * name
Definition
WM_types.hh:1030
wmOperatorType::flag
short flag
Definition
WM_types.hh:1154
wmOperatorType::exec
wmOperatorStatus(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition
WM_types.hh:1046
wmOperatorType::poll
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition
WM_types.hh:1086
wmOperatorType::idname
const char * idname
Definition
WM_types.hh:1032
wmOperatorType::description
const char * description
Definition
WM_types.hh:1036
wmOperator
Definition
DNA_windowmanager_types.h:636
wmOperator::reports
struct ReportList * reports
Definition
DNA_windowmanager_types.h:656
ot
wmOperatorType * ot
Definition
wm_files.cc:4226
Generated on Fri Apr 3 2026 06:33:18 for Blender by
doxygen
1.11.0