Blender
V5.0
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
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
21
namespace
blender::ed::object
{
22
23
/* -------------------------------------------------------------------- */
26
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
87
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:1353
DNA_camera_types.h
CAM_CUSTOM_SHADER_EXTERNAL
@ CAM_CUSTOM_SHADER_EXTERNAL
Definition
DNA_camera_types.h:168
CAM_CUSTOM
@ CAM_CUSTOM
Definition
DNA_camera_types.h:151
OB_CAMERA
@ OB_CAMERA
Definition
DNA_object_types.h:448
wmOperatorStatus
wmOperatorStatus
Definition
DNA_windowmanager_enums.h:16
OPERATOR_FINISHED
@ OPERATOR_FINISHED
Definition
DNA_windowmanager_enums.h:19
ED_object.hh
RE_engine.h
C
#define C
Definition
RandGen.cpp:29
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:118
RE_engine_free
void RE_engine_free(RenderEngine *engine)
Definition
intern/engine.cc:160
blender::ed::object
Definition
ED_object.hh:48
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:152
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:72
Camera::custom_shader
struct Text * custom_shader
Definition
DNA_camera_types.h:118
Camera::custom_filepath
char custom_filepath[1024]
Definition
DNA_camera_types.h:120
Camera::type
char type
Definition
DNA_camera_types.h:83
Camera::custom_mode
int custom_mode
Definition
DNA_camera_types.h:124
Object
Definition
DNA_object_types.h:191
Object::type
short type
Definition
DNA_object_types.h:204
Object::data
void * data
Definition
DNA_object_types.h:220
RenderEngineType
Definition
RE_engine.h:69
RenderEngineType::update_custom_camera
void(* update_custom_camera)(struct RenderEngine *engine, struct Camera *cam)
Definition
RE_engine.h:113
RenderEngine
Definition
RE_engine.h:129
RenderEngine::reports
struct ReportList * reports
Definition
RE_engine.h:143
bContext
Definition
blenkernel/intern/context.cc:63
wmOperatorType
Definition
WM_types.hh:1031
wmOperator
Definition
DNA_windowmanager_types.h:531
wmOperator::reports
struct ReportList * reports
Definition
DNA_windowmanager_types.h:551
ot
wmOperatorType * ot
Definition
wm_files.cc:4237
Generated on
for Blender by
doxygen
1.16.1