Blender V5.0
rna_camera.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_camera_types.h"
12#include "DNA_text_types.h"
13
14#include "BLI_math_rotation.h"
15
16#include "BLT_translation.hh"
17
18#include "RNA_define.hh"
19
20#include "rna_internal.hh"
21
22#include "WM_api.hh"
23#include "WM_types.hh"
24
25#ifdef RNA_RUNTIME
26
27# include <fmt/format.h>
28
29# include "BKE_camera.h"
30# include "BKE_object.hh"
31# include "BKE_report.hh"
32
33# include "DEG_depsgraph.hh"
34# include "DEG_depsgraph_build.hh"
35
36# include "SEQ_relations.hh"
37
38# include "RE_engine.h"
39
40static float rna_Camera_angle_get(PointerRNA *ptr)
41{
42 const Camera *cam = (const Camera *)ptr->owner_id;
43 float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
44 return focallength_to_fov(cam->lens, sensor);
45}
46
47static void rna_Camera_angle_set(PointerRNA *ptr, float value)
48{
49 Camera *cam = (Camera *)ptr->owner_id;
50 float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y);
51 cam->lens = fov_to_focallength(value, sensor);
52}
53
54static float rna_Camera_angle_x_get(PointerRNA *ptr)
55{
56 const Camera *cam = (const Camera *)ptr->owner_id;
57 return focallength_to_fov(cam->lens, cam->sensor_x);
58}
59
60static void rna_Camera_angle_x_set(PointerRNA *ptr, float value)
61{
62 Camera *cam = (Camera *)ptr->owner_id;
63 cam->lens = fov_to_focallength(value, cam->sensor_x);
64}
65
66static float rna_Camera_angle_y_get(PointerRNA *ptr)
67{
68 const Camera *cam = (const Camera *)ptr->owner_id;
69 return focallength_to_fov(cam->lens, cam->sensor_y);
70}
71
72static void rna_Camera_angle_y_set(PointerRNA *ptr, float value)
73{
74 Camera *cam = (Camera *)ptr->owner_id;
75 cam->lens = fov_to_focallength(value, cam->sensor_y);
76}
77
78static void rna_Camera_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
79{
80 Camera *camera = (Camera *)ptr->owner_id;
81
82 DEG_id_tag_update(&camera->id, 0);
83}
84
85static void rna_Camera_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
86{
87 Camera *camera = (Camera *)ptr->owner_id;
89 DEG_id_tag_update(&camera->id, 0);
90}
91
92static void rna_Camera_custom_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
93{
94 Camera *camera = (Camera *)ptr->owner_id;
95 RenderEngineType *engine_type = (scene != nullptr) ? RE_engines_find(scene->r.engine) : nullptr;
96
97 if (engine_type && engine_type->update_custom_camera) {
98 /* auto update camera */
99 RenderEngine *engine = RE_engine_create(engine_type);
100 engine_type->update_custom_camera(engine, camera);
101 RE_engine_free(engine);
102 }
103
104 DEG_id_tag_update(&camera->id, 0);
105}
106
107static void rna_Camera_custom_mode_set(PointerRNA *ptr, int value)
108{
109 Camera *camera = (Camera *)ptr->owner_id;
110
111 if (camera->custom_mode != value) {
112 camera->custom_mode = value;
113 camera->custom_filepath[0] = '\0';
114
115 /* replace text data-block by filepath */
116 if (camera->custom_shader) {
117 Text *text = reinterpret_cast<Text *>(camera->custom_shader);
118
119 if (value == CAM_CUSTOM_SHADER_EXTERNAL && text->filepath) {
120 STRNCPY(camera->custom_filepath, text->filepath);
121 BLI_path_abs(camera->custom_filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id));
122 BLI_path_rel(camera->custom_filepath, ID_BLEND_PATH_FROM_GLOBAL(&camera->id));
123 }
124
125 id_us_min(&camera->custom_shader->id);
126 camera->custom_shader = nullptr;
127 }
128
129 /* remove any bytecode */
130 if (camera->custom_bytecode) {
131 MEM_freeN(camera->custom_bytecode);
132 camera->custom_bytecode = nullptr;
133 }
134 camera->custom_bytecode_hash[0] = '\0';
135 }
136}
137
138static void rna_Camera_custom_bytecode_get(PointerRNA *ptr, char *value)
139{
140 Camera *camera = (Camera *)ptr->owner_id;
141 strcpy(value, (camera->custom_bytecode) ? camera->custom_bytecode : "");
142}
143
144static int rna_Camera_custom_bytecode_length(PointerRNA *ptr)
145{
146 Camera *camera = (Camera *)ptr->owner_id;
147 return (camera->custom_bytecode) ? strlen(camera->custom_bytecode) : 0;
148}
149
150static void rna_Camera_custom_bytecode_set(PointerRNA *ptr, const char *value)
151{
152 Camera *camera = (Camera *)ptr->owner_id;
153 if (camera->custom_bytecode) {
154 MEM_freeN(camera->custom_bytecode);
155 }
156
157 if (value && value[0]) {
158 camera->custom_bytecode = BLI_strdup(value);
159 }
160 else {
161 camera->custom_bytecode = nullptr;
162 }
163}
164
165static CameraBGImage *rna_Camera_background_images_new(Camera *cam)
166{
168
170
171 return bgpic;
172}
173
174static void rna_Camera_background_images_remove(Camera *cam,
175 ReportList *reports,
176 PointerRNA *bgpic_ptr)
177{
178 CameraBGImage *bgpic = static_cast<CameraBGImage *>(bgpic_ptr->data);
179 if (BLI_findindex(&cam->bg_images, bgpic) == -1) {
180 BKE_report(reports, RPT_ERROR, "Background image cannot be removed");
181 }
182
184 bgpic_ptr->invalidate();
185
187}
188
189static void rna_Camera_background_images_clear(Camera *cam)
190{
192
194}
195
196static std::optional<std::string> rna_Camera_background_image_path(const PointerRNA *ptr)
197{
198 const CameraBGImage *bgpic = static_cast<const CameraBGImage *>(ptr->data);
199 const Camera *camera = (const Camera *)ptr->owner_id;
200
201 const int bgpic_index = BLI_findindex(&camera->bg_images, bgpic);
202
203 if (bgpic_index >= 0) {
204 return fmt::format("background_images[{}]", bgpic_index);
205 }
206
207 return std::nullopt;
208}
209
211 const PointerRNA *ptr)
212{
213 const char *user = static_cast<const char *>(ptr->data);
214 const Camera *camera = (const Camera *)ptr->owner_id;
215
216 int bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, iuser));
217 if (bgpic_index >= 0) {
218 return fmt::format("background_images[{}].image_user", bgpic_index);
219 }
220
221 bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, cuser));
222 if (bgpic_index >= 0) {
223 return fmt::format("background_images[{}].clip_user", bgpic_index);
224 }
225
226 return std::nullopt;
227}
228
229static bool rna_Camera_background_images_override_apply(
230 Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
231{
232 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
233 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
234 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
236
238 "Unsupported RNA override operation on background images collection");
239
240 Camera *cam_dst = (Camera *)ptr_dst->owner_id;
241 const Camera *cam_src = (const Camera *)ptr_src->owner_id;
242
243 /* Remember that insertion operations are defined and stored in correct order, which means that
244 * even if we insert several items in a row, we always insert first one, then second one, etc.
245 * So we should always find 'anchor' constraint in both _src *and* _dst. */
246 CameraBGImage *bgpic_anchor = static_cast<CameraBGImage *>(
247 BLI_findlink(&cam_dst->bg_images, opop->subitem_reference_index));
248
249 /* If `bgpic_anchor` is nullptr, `bgpic_src` will be inserted in first position. */
250 const CameraBGImage *bgpic_src = static_cast<const CameraBGImage *>(
251 BLI_findlink(&cam_src->bg_images, opop->subitem_local_index));
252
253 if (bgpic_src == nullptr) {
254 BLI_assert(bgpic_src != nullptr);
255 return false;
256 }
257
258 CameraBGImage *bgpic_dst = BKE_camera_background_image_copy(bgpic_src, 0);
259
260 /* This handles nullptr anchor as expected by adding at head of list. */
261 BLI_insertlinkafter(&cam_dst->bg_images, bgpic_anchor, bgpic_dst);
262
263 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
264 return true;
265}
266
267static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA * /*ptr*/)
268{
271}
272
273std::optional<std::string> rna_CameraDOFSettings_path(const PointerRNA *ptr)
274{
275 /* if there is ID-data, resolve the path using the index instead of by name,
276 * since the name used is the name of the texture assigned, but the texture
277 * may be used multiple times in the same stack
278 */
279 if (ptr->owner_id) {
280 if (GS(ptr->owner_id->name) == ID_CA) {
281 return "dof";
282 }
283 }
284
285 return "";
286}
287
288static void rna_CameraDOFSettings_aperture_blades_set(PointerRNA *ptr, const int value)
289{
290 CameraDOFSettings *dofsettings = (CameraDOFSettings *)ptr->data;
291
292 if (ELEM(value, 1, 2)) {
293 if (dofsettings->aperture_blades == 0) {
294 dofsettings->aperture_blades = 3;
295 }
296 else {
297 dofsettings->aperture_blades = 0;
298 }
299 }
300 else {
301 dofsettings->aperture_blades = value;
302 }
303}
304
305#else
306
308{
309 StructRNA *srna;
310 PropertyRNA *prop;
311
312 static const EnumPropertyItem bgpic_source_items[] = {
313 {CAM_BGIMG_SOURCE_IMAGE, "IMAGE", 0, "Image", ""},
314 {CAM_BGIMG_SOURCE_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""},
315 {0, nullptr, 0, nullptr, nullptr},
316 };
317
318 static const EnumPropertyItem bgpic_camera_frame_items[] = {
319 {0, "STRETCH", 0, "Stretch", ""},
320 {CAM_BGIMG_FLAG_CAMERA_ASPECT, "FIT", 0, "Fit", ""},
322 {0, nullptr, 0, nullptr, nullptr},
323 };
324
325 static const EnumPropertyItem bgpic_display_depth_items[] = {
326 {0, "BACK", 0, "Back", ""},
327 {CAM_BGIMG_FLAG_FOREGROUND, "FRONT", 0, "Front", ""},
328 {0, nullptr, 0, nullptr, nullptr},
329 };
330
331 srna = RNA_def_struct(brna, "CameraBackgroundImage", nullptr);
332 RNA_def_struct_sdna(srna, "CameraBGImage");
334 srna, "Background Image", "Image and settings for display in the 3D View background");
335 RNA_def_struct_path_func(srna, "rna_Camera_background_image_path");
336
337 prop = RNA_def_boolean(srna,
338 "is_override_data",
339 false,
340 "Override Background Image",
341 "In a local override camera, whether this background image comes from "
342 "the linked reference camera, or is local to the override");
345 prop, nullptr, "flag", CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL);
346
348
349 prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
350 RNA_def_property_enum_sdna(prop, nullptr, "source");
351 RNA_def_property_enum_items(prop, bgpic_source_items);
352 RNA_def_property_ui_text(prop, "Background Source", "Data source used for background");
354
355 prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
356 RNA_def_property_pointer_sdna(prop, nullptr, "ima");
357 RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space");
361
362 prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
363 RNA_def_property_pointer_sdna(prop, nullptr, "clip");
364 RNA_def_property_ui_text(prop, "MovieClip", "Movie clip displayed and edited in this space");
368
369 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
371 RNA_def_property_struct_type(prop, "ImageUser");
372 RNA_def_property_pointer_sdna(prop, nullptr, "iuser");
374 prop,
375 "Image User",
376 "Parameters defining which layer, pass and frame of the image is displayed");
378
379 prop = RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE);
381 RNA_def_property_struct_type(prop, "MovieClipUser");
382 RNA_def_property_pointer_sdna(prop, nullptr, "cuser");
384 prop, "Clip User", "Parameters defining which frame of the movie clip is displayed");
386
387 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
388 RNA_def_property_float_sdna(prop, nullptr, "offset");
389 RNA_def_property_ui_text(prop, "Offset", "");
392
393 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
394 RNA_def_property_float_sdna(prop, nullptr, "scale");
395 RNA_def_property_ui_text(prop, "Scale", "Scale the background image");
399
400 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
401 RNA_def_property_float_sdna(prop, nullptr, "rotation");
403 prop, "Rotation", "Rotation for the background image (ortho view only)");
405
406 prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE);
408 RNA_def_property_ui_text(prop, "Flip Horizontally", "Flip the background image horizontally");
410
411 prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE);
413 RNA_def_property_ui_text(prop, "Flip Vertically", "Flip the background image vertically");
415
416 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
417 RNA_def_property_float_sdna(prop, nullptr, "alpha");
419 prop, "Opacity", "Image opacity to blend the image against the background color");
420 RNA_def_property_range(prop, 0.0, 1.0);
422
423 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
426 RNA_def_property_ui_text(prop, "Show Expanded", "Show the details in the user interface");
427 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
428
429 prop = RNA_def_property(srna, "use_camera_clip", PROP_BOOLEAN, PROP_NONE);
431 RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera");
433
434 prop = RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE);
436 RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background");
438
439 prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE);
442 prop, "Show On Foreground", "Show this image in front of objects in viewport");
444
445 /* expose 1 flag as a enum of 2 items */
446 prop = RNA_def_property(srna, "display_depth", PROP_ENUM, PROP_NONE);
447 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
448 RNA_def_property_enum_items(prop, bgpic_display_depth_items);
449 RNA_def_property_ui_text(prop, "Depth", "Display under or over everything");
452
453 /* expose 2 flags as a enum of 3 items */
454 prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
455 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
456 RNA_def_property_enum_items(prop, bgpic_camera_frame_items);
458 RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame");
460
462}
463
465{
466 StructRNA *srna;
467 FunctionRNA *func;
468 PropertyRNA *parm;
469
470 RNA_def_property_srna(cprop, "CameraBackgroundImages");
471 srna = RNA_def_struct(brna, "CameraBackgroundImages", nullptr);
472 RNA_def_struct_sdna(srna, "Camera");
473 RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images");
474
475 func = RNA_def_function(srna, "new", "rna_Camera_background_images_new");
476 RNA_def_function_ui_description(func, "Add new background image");
477 parm = RNA_def_pointer(
478 func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
479 RNA_def_function_return(func, parm);
480
481 func = RNA_def_function(srna, "remove", "rna_Camera_background_images_remove");
482 RNA_def_function_ui_description(func, "Remove background image");
484 parm = RNA_def_pointer(
485 func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
488
489 func = RNA_def_function(srna, "clear", "rna_Camera_background_images_clear");
490 RNA_def_function_ui_description(func, "Remove all background images");
491}
492
494{
495 StructRNA *srna;
496 PropertyRNA *prop;
497
498 static const EnumPropertyItem convergence_mode_items[] = {
499 {CAM_S3D_OFFAXIS, "OFFAXIS", 0, "Off-Axis", "Off-axis frustums converging in a plane"},
500 {CAM_S3D_PARALLEL, "PARALLEL", 0, "Parallel", "Parallel cameras with no convergence"},
502 "TOE",
503 0,
504 "Toe-in",
505 "Rotated cameras, looking at the same point at the convergence distance"},
506 {0, nullptr, 0, nullptr, nullptr},
507 };
508
509 static const EnumPropertyItem pivot_items[] = {
510 {CAM_S3D_PIVOT_LEFT, "LEFT", 0, "Left", ""},
511 {CAM_S3D_PIVOT_RIGHT, "RIGHT", 0, "Right", ""},
512 {CAM_S3D_PIVOT_CENTER, "CENTER", 0, "Center", ""},
513 {0, nullptr, 0, nullptr, nullptr},
514 };
515
516 srna = RNA_def_struct(brna, "CameraStereoData", nullptr);
517 RNA_def_struct_sdna(srna, "CameraStereoSettings");
518 RNA_def_struct_nested(brna, srna, "Camera");
519 RNA_def_struct_ui_text(srna, "Stereo", "Stereoscopy settings for a Camera data-block");
520
522
523 prop = RNA_def_property(srna, "convergence_mode", PROP_ENUM, PROP_NONE);
524 RNA_def_property_enum_items(prop, convergence_mode_items);
525 RNA_def_property_ui_text(prop, "Mode", "");
526 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
527
528 prop = RNA_def_property(srna, "pivot", PROP_ENUM, PROP_NONE);
529 RNA_def_property_enum_items(prop, pivot_items);
530 RNA_def_property_ui_text(prop, "Pivot", "");
531 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
532
533 prop = RNA_def_property(srna, "interocular_distance", PROP_FLOAT, PROP_DISTANCE);
534 RNA_def_property_range(prop, 0.0f, FLT_MAX);
535 RNA_def_property_ui_range(prop, 0.0f, 1e4f, 1, 3);
537 prop,
538 "Interocular Distance",
539 "Set the distance between the eyes - the stereo plane distance / 30 should be fine");
540 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
541
542 prop = RNA_def_property(srna, "convergence_distance", PROP_FLOAT, PROP_DISTANCE);
543 RNA_def_property_range(prop, 0.00001f, FLT_MAX);
544 RNA_def_property_ui_range(prop, 0.00001f, 15.0f, 1, 3);
546 "Convergence Plane Distance",
547 "The converge point for the stereo cameras "
548 "(often the distance between a projector and the projection screen)");
549 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
550
551 prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
552 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_S3D_SPHERICAL);
554 "Spherical Stereo",
555 "Render every pixel rotating the camera around the "
556 "middle of the interocular distance");
557 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
558
559 prop = RNA_def_property(srna, "use_pole_merge", PROP_BOOLEAN, PROP_NONE);
562 prop, "Use Pole Merge", "Fade interocular distance to 0 after the given cutoff angle");
563 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
564
565 prop = RNA_def_property(srna, "pole_merge_angle_from", PROP_FLOAT, PROP_ANGLE);
566 RNA_def_property_range(prop, 0.0f, M_PI_2);
568 prop, "Pole Merge Start Angle", "Angle at which interocular distance starts to fade to 0");
569 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
570
571 prop = RNA_def_property(srna, "pole_merge_angle_to", PROP_FLOAT, PROP_ANGLE);
572 RNA_def_property_range(prop, 0.0f, M_PI_2);
574 prop, "Pole Merge End Angle", "Angle at which interocular distance is 0");
575 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
576
578}
579
581{
582 StructRNA *srna;
583 PropertyRNA *prop;
584
585 srna = RNA_def_struct(brna, "CameraDOFSettings", nullptr);
586 RNA_def_struct_sdna(srna, "CameraDOFSettings");
587 RNA_def_struct_path_func(srna, "rna_CameraDOFSettings_path");
588 RNA_def_struct_ui_text(srna, "Depth of Field", "Depth of Field settings");
589
591
592 prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE);
593 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_DOF_ENABLED);
594 RNA_def_property_ui_text(prop, "Depth of Field", "Use Depth of Field");
595 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
596
597 prop = RNA_def_property(srna, "focus_object", PROP_POINTER, PROP_NONE);
598 RNA_def_property_struct_type(prop, "Object");
599 RNA_def_property_pointer_sdna(prop, nullptr, "focus_object");
603 prop, "Focus Object", "Use this object to define the depth of field focal point");
604 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
605
606 prop = RNA_def_property(srna, "focus_subtarget", PROP_STRING, PROP_NONE);
607 RNA_def_property_string_sdna(prop, nullptr, "focus_subtarget");
609 prop, "Focus Bone", "Use this armature bone to define the depth of field focal point");
610 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
611
612 prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE);
613 // RNA_def_property_pointer_sdna(prop, nullptr, "focus_distance");
614 RNA_def_property_range(prop, 0.0f, FLT_MAX);
615 RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 4);
617 prop, "Focus Distance", "Distance to the focus point for depth of field");
618 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
619
620 prop = RNA_def_property(srna, "aperture_fstop", PROP_FLOAT, PROP_NONE);
622 prop,
623 "F-Stop",
624 "F-Stop ratio (lower numbers give more defocus, higher numbers give a sharper image)");
625 RNA_def_property_range(prop, 0.0f, FLT_MAX);
626 RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1);
627 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
628
629 prop = RNA_def_property(srna, "aperture_blades", PROP_INT, PROP_NONE);
631 prop, "Blades", "Number of blades in aperture for polygonal bokeh (at least 3)");
632 RNA_def_property_range(prop, 0, 16);
633 RNA_def_property_int_funcs(prop, nullptr, "rna_CameraDOFSettings_aperture_blades_set", nullptr);
634 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
635
636 prop = RNA_def_property(srna, "aperture_rotation", PROP_FLOAT, PROP_ANGLE);
637 RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture");
639 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
640
641 prop = RNA_def_property(srna, "aperture_ratio", PROP_FLOAT, PROP_NONE);
642 RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh");
643 RNA_def_property_range(prop, 0.01f, FLT_MAX);
644 RNA_def_property_ui_range(prop, 0.01f, 2.0f, 0.1, 3);
645 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
646
648}
649
651{
652 StructRNA *srna;
653 PropertyRNA *prop;
654 static const EnumPropertyItem prop_type_items[] = {
655 {CAM_PERSP, "PERSP", 0, "Perspective", ""},
656 {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""},
657 {CAM_PANO, "PANO", 0, "Panoramic", ""},
658 {CAM_CUSTOM, "CUSTOM", 0, "Custom", ""},
659 {0, nullptr, 0, nullptr, nullptr},
660 };
661 static const EnumPropertyItem prop_lens_unit_items[] = {
662 {0, "MILLIMETERS", 0, "Millimeters", "Specify focal length of the lens in millimeters"},
664 "FOV",
665 0,
666 "Field of View",
667 "Specify the lens as the field of view's angle"},
668 {0, nullptr, 0, nullptr, nullptr},
669 };
670 static const EnumPropertyItem sensor_fit_items[] = {
672 "AUTO",
673 0,
674 "Auto",
675 "Fit to the sensor width or height depending on image resolution"},
676 {CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Fit to the sensor width"},
677 {CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Fit to the sensor height"},
678 {0, nullptr, 0, nullptr, nullptr},
679 };
680
681 static const EnumPropertyItem panorama_type_items[] = {
683 "EQUIRECTANGULAR",
684 0,
685 "Equirectangular",
686 "Spherical camera for environment maps, also known as Lat Long panorama"},
688 "EQUIANGULAR_CUBEMAP_FACE",
689 0,
690 "Equiangular Cubemap Face",
691 "Single face of an equiangular cubemap"},
693 "MIRRORBALL",
694 0,
695 "Mirror Ball",
696 "Mirror ball mapping for environment maps"},
698 "FISHEYE_EQUIDISTANT",
699 0,
700 "Fisheye Equidistant",
701 "Ideal for fulldomes, ignore the sensor dimensions"},
703 "FISHEYE_EQUISOLID",
704 0,
705 "Fisheye Equisolid",
706 "Similar to most fisheye modern lens, takes sensor dimensions into consideration"},
708 "FISHEYE_LENS_POLYNOMIAL",
709 0,
710 "Fisheye Lens Polynomial",
711 "Defines the lens projection as polynomial to allow real world camera lenses to be "
712 "mimicked"},
714 "CENTRAL_CYLINDRICAL",
715 0,
716 "Central Cylindrical",
717 "Projection onto a virtual cylinder from its center, similar as a rotating panoramic "
718 "camera"},
719 {0, nullptr, 0, nullptr, nullptr},
720 };
721
722 static const EnumPropertyItem custom_mode_items[] = {
723 {CAM_CUSTOM_SHADER_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text data-block"},
724 {CAM_CUSTOM_SHADER_EXTERNAL, "EXTERNAL", 0, "External", "Use external file"},
725 {0, nullptr, 0, nullptr, nullptr},
726 };
727
728 srna = RNA_def_struct(brna, "Camera", "ID");
729 RNA_def_struct_ui_text(srna, "Camera", "Camera data-block for storing camera settings");
730 RNA_def_struct_ui_icon(srna, ICON_CAMERA_DATA);
731
733
734 /* Enums */
735 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
736 RNA_def_property_enum_items(prop, prop_type_items);
737 RNA_def_property_ui_text(prop, "Type", "Camera types");
738 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
739
740 prop = RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE);
741 RNA_def_property_enum_sdna(prop, nullptr, "sensor_fit");
742 RNA_def_property_enum_items(prop, sensor_fit_items);
744 prop, "Sensor Fit", "Method to fit image and field of view angle inside the sensor");
745 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
746
747 /* Number values */
748
749 prop = RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR);
750 RNA_def_property_float_sdna(prop, nullptr, "passepartalpha");
752 prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view");
754
755 prop = RNA_def_property(srna, "angle_x", PROP_FLOAT, PROP_ANGLE);
756 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
758 RNA_def_property_ui_text(prop, "Horizontal FOV", "Camera lens horizontal field of view");
759 RNA_def_property_float_funcs(prop, "rna_Camera_angle_x_get", "rna_Camera_angle_x_set", nullptr);
760 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
761
762 prop = RNA_def_property(srna, "angle_y", PROP_FLOAT, PROP_ANGLE);
763 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
765 RNA_def_property_ui_text(prop, "Vertical FOV", "Camera lens vertical field of view");
766 RNA_def_property_float_funcs(prop, "rna_Camera_angle_y_get", "rna_Camera_angle_y_set", nullptr);
767 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
768
769 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
770 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
772 RNA_def_property_ui_text(prop, "Field of View", "Camera lens field of view");
773 RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", nullptr);
774 RNA_def_property_float_default(prop, 0.6911504f);
775 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
776
777 prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
778 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
779 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
780 RNA_def_property_ui_text(prop, "Clip Start", "Camera near clipping distance");
781 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
782
783 prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
784 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
785 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
786 RNA_def_property_ui_text(prop, "Clip End", "Camera far clipping distance");
787 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
788
789 prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_DISTANCE_CAMERA);
790 RNA_def_property_float_sdna(prop, nullptr, "lens");
791 RNA_def_property_range(prop, 1.0f, FLT_MAX);
792 RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 100, 4);
794 prop, "Focal Length", "Perspective Camera focal length value in millimeters");
795 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
796
797 prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA);
798 RNA_def_property_float_sdna(prop, nullptr, "sensor_x");
799 RNA_def_property_range(prop, 1.0f, FLT_MAX);
800 RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
802 prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters");
803 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
804
805 prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA);
806 RNA_def_property_float_sdna(prop, nullptr, "sensor_y");
807 RNA_def_property_range(prop, 1.0f, FLT_MAX);
808 RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
810 prop, "Sensor Height", "Vertical size of the image sensor area in millimeters");
811 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
812
813 prop = RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
814 RNA_def_property_float_sdna(prop, nullptr, "ortho_scale");
815 RNA_def_property_range(prop, FLT_MIN, FLT_MAX);
816 RNA_def_property_ui_range(prop, 0.001f, 10000.0f, 10, 3);
818 prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)");
819 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
820
821 prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
822 RNA_def_property_float_sdna(prop, nullptr, "drawsize");
823 RNA_def_property_range(prop, 0.01f, 1000.0f);
824 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
826 prop, "Display Size", "Apparent size of the Camera object in the 3D View");
827 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
828
829 prop = RNA_def_property(srna, "shift_x", PROP_FLOAT, PROP_NONE);
830 RNA_def_property_float_sdna(prop, nullptr, "shiftx");
831 RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
832 RNA_def_property_ui_text(prop, "Shift X", "Camera horizontal shift");
833 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
834
835 prop = RNA_def_property(srna, "shift_y", PROP_FLOAT, PROP_NONE);
836 RNA_def_property_float_sdna(prop, nullptr, "shifty");
837 RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
838 RNA_def_property_ui_text(prop, "Shift Y", "Camera vertical shift");
839 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
840
841 /* Stereo Settings */
842 prop = RNA_def_property(srna, "stereo", PROP_POINTER, PROP_NONE);
844 RNA_def_property_pointer_sdna(prop, nullptr, "stereo");
845 RNA_def_property_struct_type(prop, "CameraStereoData");
846 RNA_def_property_ui_text(prop, "Stereo", "");
847
848 /* flag */
849 prop = RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE);
850 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWLIMITS);
852 prop, "Show Limits", "Display the clipping range and focus point on the camera");
853 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
854
855 prop = RNA_def_property(srna, "show_mist", PROP_BOOLEAN, PROP_NONE);
856 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWMIST);
858 prop, "Show Mist", "Display a line from the Camera to indicate the mist area");
859 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
860
861 prop = RNA_def_property(srna, "show_passepartout", PROP_BOOLEAN, PROP_NONE);
864 prop, "Show Passepartout", "Show a darkened overlay outside the image area in Camera view");
866
867 prop = RNA_def_property(srna, "show_safe_areas", PROP_BOOLEAN, PROP_NONE);
870 prop, "Show Safe Areas", "Show TV title safe and action safe areas in Camera view");
872
873 prop = RNA_def_property(srna, "show_safe_center", PROP_BOOLEAN, PROP_NONE);
876 "Show Center-Cut Safe Areas",
877 "Show safe areas to fit content in a different aspect ratio");
879
880 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
881 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWNAME);
882 RNA_def_property_ui_text(prop, "Show Name", "Show the active Camera's name in Camera view");
884
885 prop = RNA_def_property(srna, "show_sensor", PROP_BOOLEAN, PROP_NONE);
886 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWSENSOR);
888 prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view");
890
891 prop = RNA_def_property(srna, "show_background_images", PROP_BOOLEAN, PROP_NONE);
892 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOW_BG_IMAGE);
894 prop, "Display Background Images", "Display reference images behind objects in the 3D View");
896
897 prop = RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE);
898 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
899 RNA_def_property_enum_items(prop, prop_lens_unit_items);
900 RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface");
901
902 /* dtx */
903 prop = RNA_def_property(srna, "composition_guide_color", PROP_FLOAT, PROP_COLOR);
905 prop, "Composition Guide Color", "Color and alpha for compositional guide overlays");
907
908 prop = RNA_def_property(srna, "show_composition_center", PROP_BOOLEAN, PROP_NONE);
909 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_CENTER);
911 prop, "Center", "Display center composition guide inside the camera view");
913
914 prop = RNA_def_property(srna, "show_composition_center_diagonal", PROP_BOOLEAN, PROP_NONE);
917 prop, "Center Diagonal", "Display diagonal center composition guide inside the camera view");
919
920 prop = RNA_def_property(srna, "show_composition_thirds", PROP_BOOLEAN, PROP_NONE);
921 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_THIRDS);
923 prop, "Thirds", "Display rule of thirds composition guide inside the camera view");
925
926 prop = RNA_def_property(srna, "show_composition_golden", PROP_BOOLEAN, PROP_NONE);
927 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_GOLDEN);
929 prop, "Golden Ratio", "Display golden ratio composition guide inside the camera view");
931
932 prop = RNA_def_property(srna, "show_composition_golden_tria_a", PROP_BOOLEAN, PROP_NONE);
935 "Golden Triangle A",
936 "Display golden triangle A composition guide inside the camera view");
938
939 prop = RNA_def_property(srna, "show_composition_golden_tria_b", PROP_BOOLEAN, PROP_NONE);
942 "Golden Triangle B",
943 "Display golden triangle B composition guide inside the camera view");
945
946 prop = RNA_def_property(srna, "show_composition_harmony_tri_a", PROP_BOOLEAN, PROP_NONE);
949 prop, "Harmonious Triangle A", "Display harmony A composition guide inside the camera view");
951
952 prop = RNA_def_property(srna, "show_composition_harmony_tri_b", PROP_BOOLEAN, PROP_NONE);
955 prop, "Harmonious Triangle B", "Display harmony B composition guide inside the camera view");
957
958 /* Panoramic settings. */
959 prop = RNA_def_property(srna, "panorama_type", PROP_ENUM, PROP_NONE);
960 RNA_def_property_enum_items(prop, panorama_type_items);
961 RNA_def_property_ui_text(prop, "Panorama Type", "Distortion to use for the calculation");
962 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
963
964 prop = RNA_def_property(srna, "fisheye_fov", PROP_FLOAT, PROP_ANGLE);
965 RNA_def_property_range(prop, 0.1745, 10.0 * M_PI);
966 RNA_def_property_ui_range(prop, 0.1745, 2.0 * M_PI, 3, 2);
967 RNA_def_property_ui_text(prop, "Field of View", "Field of view for the fisheye lens");
968 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
969
970 prop = RNA_def_property(srna, "fisheye_lens", PROP_FLOAT, PROP_NONE);
971 RNA_def_property_range(prop, 0.01, 100.0);
972 RNA_def_property_ui_range(prop, 0.01, 15.0, 3, 2);
973 RNA_def_property_ui_text(prop, "Fisheye Lens", "Lens focal length (mm)");
974 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
975
976 prop = RNA_def_property(srna, "latitude_min", PROP_FLOAT, PROP_ANGLE);
977 RNA_def_property_range(prop, -0.5 * M_PI, 0.5 * M_PI);
978 RNA_def_property_ui_range(prop, -0.5 * M_PI, 0.5 * M_PI, 3, 2);
980 prop, "Min Latitude", "Minimum latitude (vertical angle) for the equirectangular lens");
981 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
982
983 prop = RNA_def_property(srna, "latitude_max", PROP_FLOAT, PROP_ANGLE);
984 RNA_def_property_range(prop, -0.5 * M_PI, 0.5 * M_PI);
985 RNA_def_property_ui_range(prop, -0.5 * M_PI, 0.5 * M_PI, 3, 2);
987 prop, "Max Latitude", "Maximum latitude (vertical angle) for the equirectangular lens");
988 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
989
990 prop = RNA_def_property(srna, "longitude_min", PROP_FLOAT, PROP_ANGLE);
991 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
993 prop, "Min Longitude", "Minimum longitude (horizontal angle) for the equirectangular lens");
994 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
995
996 prop = RNA_def_property(srna, "longitude_max", PROP_FLOAT, PROP_ANGLE);
997 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
999 prop, "Max Longitude", "Maximum longitude (horizontal angle) for the equirectangular lens");
1000 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1001
1002 prop = RNA_def_property(srna, "fisheye_polynomial_k0", PROP_FLOAT, PROP_ANGLE);
1003 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1004 RNA_def_property_ui_text(prop, "Fisheye Polynomial K0", "Coefficient K0 of the lens polynomial");
1005 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1006
1007 prop = RNA_def_property(srna, "fisheye_polynomial_k1", PROP_FLOAT, PROP_ANGLE);
1008 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1009 RNA_def_property_ui_text(prop, "Fisheye Polynomial K1", "Coefficient K1 of the lens polynomial");
1010 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1011
1012 prop = RNA_def_property(srna, "fisheye_polynomial_k2", PROP_FLOAT, PROP_ANGLE);
1013 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1014 RNA_def_property_ui_text(prop, "Fisheye Polynomial K2", "Coefficient K2 of the lens polynomial");
1015 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1016
1017 prop = RNA_def_property(srna, "fisheye_polynomial_k3", PROP_FLOAT, PROP_ANGLE);
1018 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1019 RNA_def_property_ui_text(prop, "Fisheye Polynomial K3", "Coefficient K3 of the lens polynomial");
1020 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1021
1022 prop = RNA_def_property(srna, "fisheye_polynomial_k4", PROP_FLOAT, PROP_ANGLE);
1023 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1024 RNA_def_property_ui_text(prop, "Fisheye Polynomial K4", "Coefficient K4 of the lens polynomial");
1025 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1026
1027 prop = RNA_def_property(srna, "central_cylindrical_range_u_min", PROP_FLOAT, PROP_ANGLE);
1028 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
1030 prop, "Min Longitude", "Minimum Longitude value for the central cylindrical lens");
1031 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1032
1033 prop = RNA_def_property(srna, "central_cylindrical_range_u_max", PROP_FLOAT, PROP_ANGLE);
1034 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
1036 prop, "Max Longitude", "Maximum Longitude value for the central cylindrical lens");
1037 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1038
1039 prop = RNA_def_property(srna, "central_cylindrical_range_v_min", PROP_FLOAT, PROP_DISTANCE);
1040 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1f, 3);
1042 prop, "Min Height", "Minimum Height value for the central cylindrical lens");
1043 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1044
1045 prop = RNA_def_property(srna, "central_cylindrical_range_v_max", PROP_FLOAT, PROP_DISTANCE);
1046 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1f, 3);
1048 prop, "Max Height", "Maximum Height value for the central cylindrical lens");
1049 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1050
1051 prop = RNA_def_property(srna, "central_cylindrical_radius", PROP_FLOAT, PROP_DISTANCE);
1052 RNA_def_property_range(prop, 0.00001f, FLT_MAX);
1053 RNA_def_property_ui_range(prop, 0.00001f, 10.0f, 0.1f, 3);
1054 RNA_def_property_ui_text(prop, "Cylinder Radius", "Radius of the virtual cylinder");
1055 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1056
1057 /* Custom camera. */
1058 prop = RNA_def_property(srna, "custom_filepath", PROP_STRING, PROP_FILEPATH);
1060 prop, "Custom File Path", "Path to the shader defining the custom camera");
1061 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_custom_update");
1062
1063 prop = RNA_def_property(srna, "custom_shader", PROP_POINTER, PROP_NONE);
1064 RNA_def_property_struct_type(prop, "Text");
1066 RNA_def_property_ui_text(prop, "Custom Shader", "Shader defining the custom camera");
1067 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_custom_update");
1068
1069 prop = RNA_def_property(srna, "custom_mode", PROP_ENUM, PROP_NONE);
1070 RNA_def_property_enum_funcs(prop, nullptr, "rna_Camera_custom_mode_set", nullptr);
1071 RNA_def_property_enum_items(prop, custom_mode_items);
1072 RNA_def_property_ui_text(prop, "Custom shader source", "");
1073 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1074
1075 prop = RNA_def_property(srna, "custom_bytecode", PROP_STRING, PROP_NONE);
1077 "rna_Camera_custom_bytecode_get",
1078 "rna_Camera_custom_bytecode_length",
1079 "rna_Camera_custom_bytecode_set");
1080 RNA_def_property_ui_text(prop, "Custom Bytecode", "Compiled bytecode of the custom shader");
1081 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1082
1083 prop = RNA_def_property(srna, "custom_bytecode_hash", PROP_STRING, PROP_NONE);
1085 prop,
1086 "Custom Bytecode Hash",
1087 "Hash of the compiled bytecode of the custom shader, for quick equality checking");
1088 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1089
1090 /* pointers */
1091 prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE);
1092 RNA_def_property_struct_type(prop, "CameraDOFSettings");
1093 RNA_def_property_ui_text(prop, "Depth Of Field", "");
1094 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
1095
1096 prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE);
1097 RNA_def_property_collection_sdna(prop, nullptr, "bg_images", nullptr);
1098 RNA_def_property_struct_type(prop, "CameraBackgroundImage");
1099 RNA_def_property_ui_text(prop, "Background Images", "List of background images");
1102 prop, nullptr, nullptr, "rna_Camera_background_images_override_apply");
1104
1106
1108
1111
1112 /* Nested Data. */
1114
1115 /* *** Animated *** */
1118
1119 /* Camera API */
1120 RNA_api_camera(srna);
1121}
1122
1123#endif
Camera data-block and utility functions.
float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y)
struct CameraBGImage * BKE_camera_background_image_new(struct Camera *cam)
void BKE_camera_background_image_clear(struct Camera *cam)
struct CameraBGImage * BKE_camera_background_image_copy(const struct CameraBGImage *bgpic_src, int flag)
void BKE_camera_background_image_remove(struct Camera *cam, struct CameraBGImage *bgpic)
void id_us_min(ID *id)
Definition lib_id.cc:366
General operations, lookup, etc. for blender objects.
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:534
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:332
#define DEG2RAD(_deg)
#define M_PI_2
#define M_PI
float fov_to_focallength(float hfov, float sensor)
float focallength_to_fov(float focal_length, float sensor)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
char * STRNCPY(char(&dst)[N], const char *src)
Definition BLI_string.h:693
#define ELEM(...)
#define BLT_I18NCONTEXT_ID_CAMERA
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
#define ID_BLEND_PATH_FROM_GLOBAL(_id)
Definition DNA_ID.h:688
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:240
@ ID_CA
@ CAM_DOF_ENABLED
@ CAM_S3D_PARALLEL
@ CAM_S3D_OFFAXIS
@ CAM_S3D_TOE
@ CAM_S3D_SPHERICAL
@ CAM_S3D_POLE_MERGE
@ CAM_CUSTOM_SHADER_EXTERNAL
@ CAM_CUSTOM_SHADER_INTERNAL
@ CAM_PERSP
@ CAM_PANO
@ CAM_CUSTOM
@ CAM_ORTHO
@ CAM_SHOWLIMITS
@ CAM_SHOW_BG_IMAGE
@ CAM_SHOWPASSEPARTOUT
@ CAM_SHOW_SAFE_MARGINS
@ CAM_SHOW_SAFE_CENTER
@ CAM_SHOWMIST
@ CAM_ANGLETOGGLE
@ CAM_SHOWNAME
@ CAM_SHOWSENSOR
@ CAM_PANORAMA_CENTRAL_CYLINDRICAL
@ CAM_PANORAMA_FISHEYE_EQUIDISTANT
@ CAM_PANORAMA_MIRRORBALL
@ CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE
@ CAM_PANORAMA_FISHEYE_EQUISOLID
@ CAM_PANORAMA_EQUIRECTANGULAR
@ CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL
@ CAM_DTX_GOLDEN_TRI_A
@ CAM_DTX_CENTER
@ CAM_DTX_HARMONY_TRI_A
@ CAM_DTX_GOLDEN
@ CAM_DTX_GOLDEN_TRI_B
@ CAM_DTX_HARMONY_TRI_B
@ CAM_DTX_CENTER_DIAG
@ CAM_DTX_THIRDS
@ CAM_BGIMG_SOURCE_IMAGE
@ CAM_BGIMG_SOURCE_MOVIE
@ CAM_S3D_PIVOT_CENTER
@ CAM_S3D_PIVOT_RIGHT
@ CAM_S3D_PIVOT_LEFT
@ CAMERA_SENSOR_FIT_HOR
@ CAMERA_SENSOR_FIT_AUTO
@ CAMERA_SENSOR_FIT_VERT
@ CAM_BGIMG_FLAG_FLIP_X
@ CAM_BGIMG_FLAG_FLIP_Y
@ CAM_BGIMG_FLAG_CAMERA_CROP
@ CAM_BGIMG_FLAG_CAMERACLIP
@ CAM_BGIMG_FLAG_CAMERA_ASPECT
@ CAM_BGIMG_FLAG_DISABLED
@ CAM_BGIMG_FLAG_FOREGROUND
@ CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL
@ CAM_BGIMG_FLAG_EXPANDED
ParameterFlag
Definition RNA_types.hh:544
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
#define RNA_TRANSLATION_PREC_DEFAULT
Definition RNA_types.hh:224
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition RNA_types.hh:528
@ PROPOVERRIDE_NO_PROP_NAME
Definition RNA_types.hh:536
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:439
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:364
@ PROP_XYZ
Definition RNA_types.hh:269
@ PROP_DISTANCE
Definition RNA_types.hh:256
@ PROP_COLOR
Definition RNA_types.hh:260
@ PROP_ANGLE
Definition RNA_types.hh:252
@ PROP_DISTANCE_CAMERA
Definition RNA_types.hh:257
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FACTOR
Definition RNA_types.hh:251
@ PROP_FILEPATH
Definition RNA_types.hh:236
#define ND_SEQUENCER
Definition WM_types.hh:437
#define ND_DRAW
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:378
#define NC_CAMERA
Definition WM_types.hh:401
#define NC_OBJECT
Definition WM_types.hh:379
#define ND_DRAW_RENDER_VIEWPORT
Definition WM_types.hh:470
#define offsetof(t, d)
#define GS(x)
RenderEngineType * RE_engines_find(const char *idname)
RenderEngine * RE_engine_create(RenderEngineType *type)
void RE_engine_free(RenderEngine *engine)
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void relations_invalidate_scene_strips(const Main *bmain, const Scene *scene_target)
void RNA_property_update_main(Main *bmain, Scene *scene, PointerRNA *ptr, PropertyRNA *prop)
void rna_def_animdata_common(StructRNA *srna)
static void rna_def_camera_stereo_data(BlenderRNA *brna)
void RNA_def_camera(BlenderRNA *brna)
static void rna_def_camera_dof_settings_data(BlenderRNA *brna)
static void rna_def_camera_background_image(BlenderRNA *brna)
static void rna_def_camera_background_images(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_api_camera(StructRNA *srna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_define_animate_sdna(bool animate)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
std::optional< std::string > rna_CameraBackgroundImage_image_or_movieclip_user_path(const PointerRNA *ptr)
#define FLT_MAX
Definition stdcycles.h:14
struct ListBase bg_images
ID * owner_id
Definition RNA_types.hh:51
void invalidate()
Definition RNA_types.hh:110
void * data
Definition RNA_types.hh:53
IDOverrideLibraryPropertyOperation * liboverride_operation
void(* update_custom_camera)(struct RenderEngine *engine, struct Camera *cam)
Definition RE_engine.h:113
char * filepath
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238