Blender V4.5
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_rel(camera->custom_filepath, BKE_main_blendfile_path_from_global());
122 }
123
124 id_us_min(&camera->custom_shader->id);
125 camera->custom_shader = nullptr;
126 }
127
128 /* remove any bytecode */
129 if (camera->custom_bytecode) {
130 MEM_freeN(camera->custom_bytecode);
131 camera->custom_bytecode = nullptr;
132 }
133 camera->custom_bytecode_hash[0] = '\0';
134 }
135}
136
137static void rna_Camera_custom_bytecode_get(PointerRNA *ptr, char *value)
138{
139 Camera *camera = (Camera *)ptr->owner_id;
140 strcpy(value, (camera->custom_bytecode) ? camera->custom_bytecode : "");
141}
142
143static int rna_Camera_custom_bytecode_length(PointerRNA *ptr)
144{
145 Camera *camera = (Camera *)ptr->owner_id;
146 return (camera->custom_bytecode) ? strlen(camera->custom_bytecode) : 0;
147}
148
149static void rna_Camera_custom_bytecode_set(PointerRNA *ptr, const char *value)
150{
151 Camera *camera = (Camera *)ptr->owner_id;
152 if (camera->custom_bytecode) {
153 MEM_freeN(camera->custom_bytecode);
154 }
155
156 if (value && value[0]) {
157 camera->custom_bytecode = BLI_strdup(value);
158 }
159 else {
160 camera->custom_bytecode = nullptr;
161 }
162}
163
164static CameraBGImage *rna_Camera_background_images_new(Camera *cam)
165{
167
169
170 return bgpic;
171}
172
173static void rna_Camera_background_images_remove(Camera *cam,
175 PointerRNA *bgpic_ptr)
176{
177 CameraBGImage *bgpic = static_cast<CameraBGImage *>(bgpic_ptr->data);
178 if (BLI_findindex(&cam->bg_images, bgpic) == -1) {
179 BKE_report(reports, RPT_ERROR, "Background image cannot be removed");
180 }
181
183 bgpic_ptr->invalidate();
184
186}
187
188static void rna_Camera_background_images_clear(Camera *cam)
189{
191
193}
194
195static std::optional<std::string> rna_Camera_background_image_path(const PointerRNA *ptr)
196{
197 const CameraBGImage *bgpic = static_cast<const CameraBGImage *>(ptr->data);
198 const Camera *camera = (const Camera *)ptr->owner_id;
199
200 const int bgpic_index = BLI_findindex(&camera->bg_images, bgpic);
201
202 if (bgpic_index >= 0) {
203 return fmt::format("background_images[{}]", bgpic_index);
204 }
205
206 return std::nullopt;
207}
208
210 const PointerRNA *ptr)
211{
212 const char *user = static_cast<const char *>(ptr->data);
213 const Camera *camera = (const Camera *)ptr->owner_id;
214
215 int bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, iuser));
216 if (bgpic_index >= 0) {
217 return fmt::format("background_images[{}].image_user", bgpic_index);
218 }
219
220 bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, cuser));
221 if (bgpic_index >= 0) {
222 return fmt::format("background_images[{}].clip_user", bgpic_index);
223 }
224
225 return std::nullopt;
226}
227
228static bool rna_Camera_background_images_override_apply(
229 Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx)
230{
231 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
232 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
233 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
235
237 "Unsupported RNA override operation on background images collection");
238
239 Camera *cam_dst = (Camera *)ptr_dst->owner_id;
240 const Camera *cam_src = (const Camera *)ptr_src->owner_id;
241
242 /* Remember that insertion operations are defined and stored in correct order, which means that
243 * even if we insert several items in a row, we always insert first one, then second one, etc.
244 * So we should always find 'anchor' constraint in both _src *and* _dst. */
245 CameraBGImage *bgpic_anchor = static_cast<CameraBGImage *>(
246 BLI_findlink(&cam_dst->bg_images, opop->subitem_reference_index));
247
248 /* If `bgpic_anchor` is nullptr, `bgpic_src` will be inserted in first position. */
249 const CameraBGImage *bgpic_src = static_cast<const CameraBGImage *>(
250 BLI_findlink(&cam_src->bg_images, opop->subitem_local_index));
251
252 if (bgpic_src == nullptr) {
253 BLI_assert(bgpic_src != nullptr);
254 return false;
255 }
256
257 CameraBGImage *bgpic_dst = BKE_camera_background_image_copy(bgpic_src, 0);
258
259 /* This handles nullptr anchor as expected by adding at head of list. */
260 BLI_insertlinkafter(&cam_dst->bg_images, bgpic_anchor, bgpic_dst);
261
262 RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
263 return true;
264}
265
266static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA * /*ptr*/)
267{
270}
271
272std::optional<std::string> rna_CameraDOFSettings_path(const PointerRNA *ptr)
273{
274 /* if there is ID-data, resolve the path using the index instead of by name,
275 * since the name used is the name of the texture assigned, but the texture
276 * may be used multiple times in the same stack
277 */
278 if (ptr->owner_id) {
279 if (GS(ptr->owner_id->name) == ID_CA) {
280 return "dof";
281 }
282 }
283
284 return "";
285}
286
287static void rna_CameraDOFSettings_aperture_blades_set(PointerRNA *ptr, const int value)
288{
289 CameraDOFSettings *dofsettings = (CameraDOFSettings *)ptr->data;
290
291 if (ELEM(value, 1, 2)) {
292 if (dofsettings->aperture_blades == 0) {
293 dofsettings->aperture_blades = 3;
294 }
295 else {
296 dofsettings->aperture_blades = 0;
297 }
298 }
299 else {
300 dofsettings->aperture_blades = value;
301 }
302}
303
304#else
305
307{
308 StructRNA *srna;
309 PropertyRNA *prop;
310
311 static const EnumPropertyItem bgpic_source_items[] = {
312 {CAM_BGIMG_SOURCE_IMAGE, "IMAGE", 0, "Image", ""},
313 {CAM_BGIMG_SOURCE_MOVIE, "MOVIE_CLIP", 0, "Movie Clip", ""},
314 {0, nullptr, 0, nullptr, nullptr},
315 };
316
317 static const EnumPropertyItem bgpic_camera_frame_items[] = {
318 {0, "STRETCH", 0, "Stretch", ""},
319 {CAM_BGIMG_FLAG_CAMERA_ASPECT, "FIT", 0, "Fit", ""},
321 {0, nullptr, 0, nullptr, nullptr},
322 };
323
324 static const EnumPropertyItem bgpic_display_depth_items[] = {
325 {0, "BACK", 0, "Back", ""},
326 {CAM_BGIMG_FLAG_FOREGROUND, "FRONT", 0, "Front", ""},
327 {0, nullptr, 0, nullptr, nullptr},
328 };
329
330 srna = RNA_def_struct(brna, "CameraBackgroundImage", nullptr);
331 RNA_def_struct_sdna(srna, "CameraBGImage");
333 srna, "Background Image", "Image and settings for display in the 3D View background");
334 RNA_def_struct_path_func(srna, "rna_Camera_background_image_path");
335
336 prop = RNA_def_boolean(srna,
337 "is_override_data",
338 false,
339 "Override Background Image",
340 "In a local override camera, whether this background image comes from "
341 "the linked reference camera, or is local to the override");
344 prop, nullptr, "flag", CAM_BGIMG_FLAG_OVERRIDE_LIBRARY_LOCAL);
345
347
348 prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE);
349 RNA_def_property_enum_sdna(prop, nullptr, "source");
350 RNA_def_property_enum_items(prop, bgpic_source_items);
351 RNA_def_property_ui_text(prop, "Background Source", "Data source used for background");
353
354 prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
355 RNA_def_property_pointer_sdna(prop, nullptr, "ima");
356 RNA_def_property_ui_text(prop, "Image", "Image displayed and edited in this space");
360
361 prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
362 RNA_def_property_pointer_sdna(prop, nullptr, "clip");
363 RNA_def_property_ui_text(prop, "MovieClip", "Movie clip displayed and edited in this space");
367
368 prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
370 RNA_def_property_struct_type(prop, "ImageUser");
371 RNA_def_property_pointer_sdna(prop, nullptr, "iuser");
373 prop,
374 "Image User",
375 "Parameters defining which layer, pass and frame of the image is displayed");
377
378 prop = RNA_def_property(srna, "clip_user", PROP_POINTER, PROP_NONE);
380 RNA_def_property_struct_type(prop, "MovieClipUser");
381 RNA_def_property_pointer_sdna(prop, nullptr, "cuser");
383 prop, "Clip User", "Parameters defining which frame of the movie clip is displayed");
385
386 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
387 RNA_def_property_float_sdna(prop, nullptr, "offset");
388 RNA_def_property_ui_text(prop, "Offset", "");
391
392 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
393 RNA_def_property_float_sdna(prop, nullptr, "scale");
394 RNA_def_property_ui_text(prop, "Scale", "Scale the background image");
398
399 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
400 RNA_def_property_float_sdna(prop, nullptr, "rotation");
402 prop, "Rotation", "Rotation for the background image (ortho view only)");
404
405 prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE);
407 RNA_def_property_ui_text(prop, "Flip Horizontally", "Flip the background image horizontally");
409
410 prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE);
412 RNA_def_property_ui_text(prop, "Flip Vertically", "Flip the background image vertically");
414
415 prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_FACTOR);
416 RNA_def_property_float_sdna(prop, nullptr, "alpha");
418 prop, "Opacity", "Image opacity to blend the image against the background color");
419 RNA_def_property_range(prop, 0.0, 1.0);
421
422 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
425 RNA_def_property_ui_text(prop, "Show Expanded", "Show the details in the user interface");
426 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
427
428 prop = RNA_def_property(srna, "use_camera_clip", PROP_BOOLEAN, PROP_NONE);
430 RNA_def_property_ui_text(prop, "Camera Clip", "Use movie clip from active scene camera");
432
433 prop = RNA_def_property(srna, "show_background_image", PROP_BOOLEAN, PROP_NONE);
435 RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background");
437
438 prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE);
441 prop, "Show On Foreground", "Show this image in front of objects in viewport");
443
444 /* expose 1 flag as a enum of 2 items */
445 prop = RNA_def_property(srna, "display_depth", PROP_ENUM, PROP_NONE);
446 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
447 RNA_def_property_enum_items(prop, bgpic_display_depth_items);
448 RNA_def_property_ui_text(prop, "Depth", "Display under or over everything");
451
452 /* expose 2 flags as a enum of 3 items */
453 prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
454 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
455 RNA_def_property_enum_items(prop, bgpic_camera_frame_items);
456 RNA_def_property_ui_text(prop, "Frame Method", "How the image fits in the camera frame");
458
460}
461
463{
464 StructRNA *srna;
465 FunctionRNA *func;
466 PropertyRNA *parm;
467
468 RNA_def_property_srna(cprop, "CameraBackgroundImages");
469 srna = RNA_def_struct(brna, "CameraBackgroundImages", nullptr);
470 RNA_def_struct_sdna(srna, "Camera");
471 RNA_def_struct_ui_text(srna, "Background Images", "Collection of background images");
472
473 func = RNA_def_function(srna, "new", "rna_Camera_background_images_new");
474 RNA_def_function_ui_description(func, "Add new background image");
475 parm = RNA_def_pointer(
476 func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
477 RNA_def_function_return(func, parm);
478
479 func = RNA_def_function(srna, "remove", "rna_Camera_background_images_remove");
480 RNA_def_function_ui_description(func, "Remove background image");
482 parm = RNA_def_pointer(
483 func, "image", "CameraBackgroundImage", "", "Image displayed as viewport background");
486
487 func = RNA_def_function(srna, "clear", "rna_Camera_background_images_clear");
488 RNA_def_function_ui_description(func, "Remove all background images");
489}
490
492{
493 StructRNA *srna;
494 PropertyRNA *prop;
495
496 static const EnumPropertyItem convergence_mode_items[] = {
497 {CAM_S3D_OFFAXIS, "OFFAXIS", 0, "Off-Axis", "Off-axis frustums converging in a plane"},
498 {CAM_S3D_PARALLEL, "PARALLEL", 0, "Parallel", "Parallel cameras with no convergence"},
500 "TOE",
501 0,
502 "Toe-in",
503 "Rotated cameras, looking at the same point at the convergence distance"},
504 {0, nullptr, 0, nullptr, nullptr},
505 };
506
507 static const EnumPropertyItem pivot_items[] = {
508 {CAM_S3D_PIVOT_LEFT, "LEFT", 0, "Left", ""},
509 {CAM_S3D_PIVOT_RIGHT, "RIGHT", 0, "Right", ""},
510 {CAM_S3D_PIVOT_CENTER, "CENTER", 0, "Center", ""},
511 {0, nullptr, 0, nullptr, nullptr},
512 };
513
514 srna = RNA_def_struct(brna, "CameraStereoData", nullptr);
515 RNA_def_struct_sdna(srna, "CameraStereoSettings");
516 RNA_def_struct_nested(brna, srna, "Camera");
517 RNA_def_struct_ui_text(srna, "Stereo", "Stereoscopy settings for a Camera data-block");
518
520
521 prop = RNA_def_property(srna, "convergence_mode", PROP_ENUM, PROP_NONE);
522 RNA_def_property_enum_items(prop, convergence_mode_items);
523 RNA_def_property_ui_text(prop, "Mode", "");
524 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
525
526 prop = RNA_def_property(srna, "pivot", PROP_ENUM, PROP_NONE);
527 RNA_def_property_enum_items(prop, pivot_items);
528 RNA_def_property_ui_text(prop, "Pivot", "");
529 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
530
531 prop = RNA_def_property(srna, "interocular_distance", PROP_FLOAT, PROP_DISTANCE);
532 RNA_def_property_range(prop, 0.0f, FLT_MAX);
533 RNA_def_property_ui_range(prop, 0.0f, 1e4f, 1, 3);
535 prop,
536 "Interocular Distance",
537 "Set the distance between the eyes - the stereo plane distance / 30 should be fine");
538 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
539
540 prop = RNA_def_property(srna, "convergence_distance", PROP_FLOAT, PROP_DISTANCE);
541 RNA_def_property_range(prop, 0.00001f, FLT_MAX);
542 RNA_def_property_ui_range(prop, 0.00001f, 15.0f, 1, 3);
544 "Convergence Plane Distance",
545 "The converge point for the stereo cameras "
546 "(often the distance between a projector and the projection screen)");
547 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
548
549 prop = RNA_def_property(srna, "use_spherical_stereo", PROP_BOOLEAN, PROP_NONE);
550 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_S3D_SPHERICAL);
552 "Spherical Stereo",
553 "Render every pixel rotating the camera around the "
554 "middle of the interocular distance");
555 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
556
557 prop = RNA_def_property(srna, "use_pole_merge", PROP_BOOLEAN, PROP_NONE);
560 prop, "Use Pole Merge", "Fade interocular distance to 0 after the given cutoff angle");
561 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
562
563 prop = RNA_def_property(srna, "pole_merge_angle_from", PROP_FLOAT, PROP_ANGLE);
564 RNA_def_property_range(prop, 0.0f, M_PI_2);
566 prop, "Pole Merge Start Angle", "Angle at which interocular distance starts to fade to 0");
567 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
568
569 prop = RNA_def_property(srna, "pole_merge_angle_to", PROP_FLOAT, PROP_ANGLE);
570 RNA_def_property_range(prop, 0.0f, M_PI_2);
572 prop, "Pole Merge End Angle", "Angle at which interocular distance is 0");
573 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
574
576}
577
579{
580 StructRNA *srna;
581 PropertyRNA *prop;
582
583 srna = RNA_def_struct(brna, "CameraDOFSettings", nullptr);
584 RNA_def_struct_sdna(srna, "CameraDOFSettings");
585 RNA_def_struct_path_func(srna, "rna_CameraDOFSettings_path");
586 RNA_def_struct_ui_text(srna, "Depth of Field", "Depth of Field settings");
587
589
590 prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE);
591 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_DOF_ENABLED);
592 RNA_def_property_ui_text(prop, "Depth of Field", "Use Depth of Field");
593 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
594
595 prop = RNA_def_property(srna, "focus_object", PROP_POINTER, PROP_NONE);
596 RNA_def_property_struct_type(prop, "Object");
597 RNA_def_property_pointer_sdna(prop, nullptr, "focus_object");
601 prop, "Focus Object", "Use this object to define the depth of field focal point");
602 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
603
604 prop = RNA_def_property(srna, "focus_subtarget", PROP_STRING, PROP_NONE);
605 RNA_def_property_string_sdna(prop, nullptr, "focus_subtarget");
607 prop, "Focus Bone", "Use this armature bone to define the depth of field focal point");
608 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update");
609
610 prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE);
611 // RNA_def_property_pointer_sdna(prop, nullptr, "focus_distance");
612 RNA_def_property_range(prop, 0.0f, FLT_MAX);
613 RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 4);
615 prop, "Focus Distance", "Distance to the focus point for depth of field");
616 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
617
618 prop = RNA_def_property(srna, "aperture_fstop", PROP_FLOAT, PROP_NONE);
620 prop,
621 "F-Stop",
622 "F-Stop ratio (lower numbers give more defocus, higher numbers give a sharper image)");
623 RNA_def_property_range(prop, 0.0f, FLT_MAX);
624 RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1);
625 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
626
627 prop = RNA_def_property(srna, "aperture_blades", PROP_INT, PROP_NONE);
629 prop, "Blades", "Number of blades in aperture for polygonal bokeh (at least 3)");
630 RNA_def_property_range(prop, 0, 16);
631 RNA_def_property_int_funcs(prop, nullptr, "rna_CameraDOFSettings_aperture_blades_set", nullptr);
632 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
633
634 prop = RNA_def_property(srna, "aperture_rotation", PROP_FLOAT, PROP_ANGLE);
635 RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture");
637 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
638
639 prop = RNA_def_property(srna, "aperture_ratio", PROP_FLOAT, PROP_NONE);
640 RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh");
641 RNA_def_property_range(prop, 0.01f, FLT_MAX);
642 RNA_def_property_ui_range(prop, 0.01f, 2.0f, 0.1, 3);
643 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update");
644
646}
647
649{
650 StructRNA *srna;
651 PropertyRNA *prop;
652 static const EnumPropertyItem prop_type_items[] = {
653 {CAM_PERSP, "PERSP", 0, "Perspective", ""},
654 {CAM_ORTHO, "ORTHO", 0, "Orthographic", ""},
655 {CAM_PANO, "PANO", 0, "Panoramic", ""},
656 {CAM_CUSTOM, "CUSTOM", 0, "Custom", ""},
657 {0, nullptr, 0, nullptr, nullptr},
658 };
659 static const EnumPropertyItem prop_lens_unit_items[] = {
660 {0, "MILLIMETERS", 0, "Millimeters", "Specify focal length of the lens in millimeters"},
662 "FOV",
663 0,
664 "Field of View",
665 "Specify the lens as the field of view's angle"},
666 {0, nullptr, 0, nullptr, nullptr},
667 };
668 static const EnumPropertyItem sensor_fit_items[] = {
670 "AUTO",
671 0,
672 "Auto",
673 "Fit to the sensor width or height depending on image resolution"},
674 {CAMERA_SENSOR_FIT_HOR, "HORIZONTAL", 0, "Horizontal", "Fit to the sensor width"},
675 {CAMERA_SENSOR_FIT_VERT, "VERTICAL", 0, "Vertical", "Fit to the sensor height"},
676 {0, nullptr, 0, nullptr, nullptr},
677 };
678
679 static const EnumPropertyItem panorama_type_items[] = {
681 "EQUIRECTANGULAR",
682 0,
683 "Equirectangular",
684 "Spherical camera for environment maps, also known as Lat Long panorama"},
686 "EQUIANGULAR_CUBEMAP_FACE",
687 0,
688 "Equiangular Cubemap Face",
689 "Single face of an equiangular cubemap"},
691 "MIRRORBALL",
692 0,
693 "Mirror Ball",
694 "Mirror ball mapping for environment maps"},
696 "FISHEYE_EQUIDISTANT",
697 0,
698 "Fisheye Equidistant",
699 "Ideal for fulldomes, ignore the sensor dimensions"},
701 "FISHEYE_EQUISOLID",
702 0,
703 "Fisheye Equisolid",
704 "Similar to most fisheye modern lens, takes sensor dimensions into consideration"},
706 "FISHEYE_LENS_POLYNOMIAL",
707 0,
708 "Fisheye Lens Polynomial",
709 "Defines the lens projection as polynomial to allow real world camera lenses to be "
710 "mimicked"},
712 "CENTRAL_CYLINDRICAL",
713 0,
714 "Central Cylindrical",
715 "Projection onto a virtual cylinder from its center, similar as a rotating panoramic "
716 "camera"},
717 {0, nullptr, 0, nullptr, nullptr},
718 };
719
720 static const EnumPropertyItem custom_mode_items[] = {
721 {CAM_CUSTOM_SHADER_INTERNAL, "INTERNAL", 0, "Internal", "Use internal text data-block"},
722 {CAM_CUSTOM_SHADER_EXTERNAL, "EXTERNAL", 0, "External", "Use external file"},
723 {0, nullptr, 0, nullptr, nullptr},
724 };
725
726 srna = RNA_def_struct(brna, "Camera", "ID");
727 RNA_def_struct_ui_text(srna, "Camera", "Camera data-block for storing camera settings");
728 RNA_def_struct_ui_icon(srna, ICON_CAMERA_DATA);
729
731
732 /* Enums */
733 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
734 RNA_def_property_enum_items(prop, prop_type_items);
735 RNA_def_property_ui_text(prop, "Type", "Camera types");
736 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
737
738 prop = RNA_def_property(srna, "sensor_fit", PROP_ENUM, PROP_NONE);
739 RNA_def_property_enum_sdna(prop, nullptr, "sensor_fit");
740 RNA_def_property_enum_items(prop, sensor_fit_items);
742 prop, "Sensor Fit", "Method to fit image and field of view angle inside the sensor");
743 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
744
745 /* Number values */
746
747 prop = RNA_def_property(srna, "passepartout_alpha", PROP_FLOAT, PROP_FACTOR);
748 RNA_def_property_float_sdna(prop, nullptr, "passepartalpha");
750 prop, "Passepartout Alpha", "Opacity (alpha) of the darkened overlay in Camera view");
752
753 prop = RNA_def_property(srna, "angle_x", PROP_FLOAT, PROP_ANGLE);
754 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
756 RNA_def_property_ui_text(prop, "Horizontal FOV", "Camera lens horizontal field of view");
757 RNA_def_property_float_funcs(prop, "rna_Camera_angle_x_get", "rna_Camera_angle_x_set", nullptr);
758 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
759
760 prop = RNA_def_property(srna, "angle_y", PROP_FLOAT, PROP_ANGLE);
761 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
763 RNA_def_property_ui_text(prop, "Vertical FOV", "Camera lens vertical field of view");
764 RNA_def_property_float_funcs(prop, "rna_Camera_angle_y_get", "rna_Camera_angle_y_set", nullptr);
765 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
766
767 prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
768 RNA_def_property_range(prop, DEG2RAD(0.367), DEG2RAD(172.847));
770 RNA_def_property_ui_text(prop, "Field of View", "Camera lens field of view");
771 RNA_def_property_float_funcs(prop, "rna_Camera_angle_get", "rna_Camera_angle_set", nullptr);
772 RNA_def_property_float_default(prop, 0.6911504f);
773 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
774
775 prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
776 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
777 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
778 RNA_def_property_ui_text(prop, "Clip Start", "Camera near clipping distance");
779 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
780
781 prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
782 RNA_def_property_range(prop, 1e-6f, FLT_MAX);
783 RNA_def_property_ui_range(prop, 0.001f, FLT_MAX, 10, 3);
784 RNA_def_property_ui_text(prop, "Clip End", "Camera far clipping distance");
785 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
786
787 prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_DISTANCE_CAMERA);
788 RNA_def_property_float_sdna(prop, nullptr, "lens");
789 RNA_def_property_range(prop, 1.0f, FLT_MAX);
790 RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 100, 4);
792 prop, "Focal Length", "Perspective Camera focal length value in millimeters");
793 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
794
795 prop = RNA_def_property(srna, "sensor_width", PROP_FLOAT, PROP_DISTANCE_CAMERA);
796 RNA_def_property_float_sdna(prop, nullptr, "sensor_x");
797 RNA_def_property_range(prop, 1.0f, FLT_MAX);
798 RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
800 prop, "Sensor Width", "Horizontal size of the image sensor area in millimeters");
801 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
802
803 prop = RNA_def_property(srna, "sensor_height", PROP_FLOAT, PROP_DISTANCE_CAMERA);
804 RNA_def_property_float_sdna(prop, nullptr, "sensor_y");
805 RNA_def_property_range(prop, 1.0f, FLT_MAX);
806 RNA_def_property_ui_range(prop, 1.0f, 100.0f, 100, 4);
808 prop, "Sensor Height", "Vertical size of the image sensor area in millimeters");
809 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
810
811 prop = RNA_def_property(srna, "ortho_scale", PROP_FLOAT, PROP_NONE);
812 RNA_def_property_float_sdna(prop, nullptr, "ortho_scale");
813 RNA_def_property_range(prop, FLT_MIN, FLT_MAX);
814 RNA_def_property_ui_range(prop, 0.001f, 10000.0f, 10, 3);
816 prop, "Orthographic Scale", "Orthographic Camera scale (similar to zoom)");
817 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
818
819 prop = RNA_def_property(srna, "display_size", PROP_FLOAT, PROP_DISTANCE);
820 RNA_def_property_float_sdna(prop, nullptr, "drawsize");
821 RNA_def_property_range(prop, 0.01f, 1000.0f);
822 RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
824 prop, "Display Size", "Apparent size of the Camera object in the 3D View");
825 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
826
827 prop = RNA_def_property(srna, "shift_x", PROP_FLOAT, PROP_NONE);
828 RNA_def_property_float_sdna(prop, nullptr, "shiftx");
829 RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
830 RNA_def_property_ui_text(prop, "Shift X", "Camera horizontal shift");
831 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
832
833 prop = RNA_def_property(srna, "shift_y", PROP_FLOAT, PROP_NONE);
834 RNA_def_property_float_sdna(prop, nullptr, "shifty");
835 RNA_def_property_ui_range(prop, -2.0, 2.0, 1, 3);
836 RNA_def_property_ui_text(prop, "Shift Y", "Camera vertical shift");
837 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
838
839 /* Stereo Settings */
840 prop = RNA_def_property(srna, "stereo", PROP_POINTER, PROP_NONE);
842 RNA_def_property_pointer_sdna(prop, nullptr, "stereo");
843 RNA_def_property_struct_type(prop, "CameraStereoData");
844 RNA_def_property_ui_text(prop, "Stereo", "");
845
846 /* flag */
847 prop = RNA_def_property(srna, "show_limits", PROP_BOOLEAN, PROP_NONE);
848 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWLIMITS);
850 prop, "Show Limits", "Display the clipping range and focus point on the camera");
851 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
852
853 prop = RNA_def_property(srna, "show_mist", PROP_BOOLEAN, PROP_NONE);
854 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWMIST);
856 prop, "Show Mist", "Display a line from the Camera to indicate the mist area");
857 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
858
859 prop = RNA_def_property(srna, "show_passepartout", PROP_BOOLEAN, PROP_NONE);
862 prop, "Show Passepartout", "Show a darkened overlay outside the image area in Camera view");
864
865 prop = RNA_def_property(srna, "show_safe_areas", PROP_BOOLEAN, PROP_NONE);
868 prop, "Show Safe Areas", "Show TV title safe and action safe areas in Camera view");
870
871 prop = RNA_def_property(srna, "show_safe_center", PROP_BOOLEAN, PROP_NONE);
874 "Show Center-Cut Safe Areas",
875 "Show safe areas to fit content in a different aspect ratio");
877
878 prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
879 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWNAME);
880 RNA_def_property_ui_text(prop, "Show Name", "Show the active Camera's name in Camera view");
882
883 prop = RNA_def_property(srna, "show_sensor", PROP_BOOLEAN, PROP_NONE);
884 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOWSENSOR);
886 prop, "Show Sensor Size", "Show sensor size (film gate) in Camera view");
888
889 prop = RNA_def_property(srna, "show_background_images", PROP_BOOLEAN, PROP_NONE);
890 RNA_def_property_boolean_sdna(prop, nullptr, "flag", CAM_SHOW_BG_IMAGE);
892 prop, "Display Background Images", "Display reference images behind objects in the 3D View");
894
895 prop = RNA_def_property(srna, "lens_unit", PROP_ENUM, PROP_NONE);
896 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
897 RNA_def_property_enum_items(prop, prop_lens_unit_items);
898 RNA_def_property_ui_text(prop, "Lens Unit", "Unit to edit lens in for the user interface");
899
900 /* dtx */
901 prop = RNA_def_property(srna, "show_composition_center", PROP_BOOLEAN, PROP_NONE);
902 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_CENTER);
904 prop, "Center", "Display center composition guide inside the camera view");
906
907 prop = RNA_def_property(srna, "show_composition_center_diagonal", PROP_BOOLEAN, PROP_NONE);
910 prop, "Center Diagonal", "Display diagonal center composition guide inside the camera view");
912
913 prop = RNA_def_property(srna, "show_composition_thirds", PROP_BOOLEAN, PROP_NONE);
914 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_THIRDS);
916 prop, "Thirds", "Display rule of thirds composition guide inside the camera view");
918
919 prop = RNA_def_property(srna, "show_composition_golden", PROP_BOOLEAN, PROP_NONE);
920 RNA_def_property_boolean_sdna(prop, nullptr, "dtx", CAM_DTX_GOLDEN);
922 prop, "Golden Ratio", "Display golden ratio composition guide inside the camera view");
924
925 prop = RNA_def_property(srna, "show_composition_golden_tria_a", PROP_BOOLEAN, PROP_NONE);
928 "Golden Triangle A",
929 "Display golden triangle A composition guide inside the camera view");
931
932 prop = RNA_def_property(srna, "show_composition_golden_tria_b", PROP_BOOLEAN, PROP_NONE);
935 "Golden Triangle B",
936 "Display golden triangle B composition guide inside the camera view");
938
939 prop = RNA_def_property(srna, "show_composition_harmony_tri_a", PROP_BOOLEAN, PROP_NONE);
942 prop, "Harmonious Triangle A", "Display harmony A composition guide inside the camera view");
944
945 prop = RNA_def_property(srna, "show_composition_harmony_tri_b", PROP_BOOLEAN, PROP_NONE);
948 prop, "Harmonious Triangle B", "Display harmony B composition guide inside the camera view");
950
951 /* Panoramic settings. */
952 prop = RNA_def_property(srna, "panorama_type", PROP_ENUM, PROP_NONE);
953 RNA_def_property_enum_items(prop, panorama_type_items);
954 RNA_def_property_ui_text(prop, "Panorama Type", "Distortion to use for the calculation");
955 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
956
957 prop = RNA_def_property(srna, "fisheye_fov", PROP_FLOAT, PROP_ANGLE);
958 RNA_def_property_range(prop, 0.1745, 10.0 * M_PI);
959 RNA_def_property_ui_range(prop, 0.1745, 2.0 * M_PI, 3, 2);
960 RNA_def_property_ui_text(prop, "Field of View", "Field of view for the fisheye lens");
961 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
962
963 prop = RNA_def_property(srna, "fisheye_lens", PROP_FLOAT, PROP_NONE);
964 RNA_def_property_range(prop, 0.01, 100.0);
965 RNA_def_property_ui_range(prop, 0.01, 15.0, 3, 2);
966 RNA_def_property_ui_text(prop, "Fisheye Lens", "Lens focal length (mm)");
967 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
968
969 prop = RNA_def_property(srna, "latitude_min", PROP_FLOAT, PROP_ANGLE);
970 RNA_def_property_range(prop, -0.5 * M_PI, 0.5 * M_PI);
971 RNA_def_property_ui_range(prop, -0.5 * M_PI, 0.5 * M_PI, 3, 2);
973 prop, "Min Latitude", "Minimum latitude (vertical angle) for the equirectangular lens");
974 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
975
976 prop = RNA_def_property(srna, "latitude_max", 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, "Max Latitude", "Maximum 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, "longitude_min", PROP_FLOAT, PROP_ANGLE);
984 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
986 prop, "Min Longitude", "Minimum longitude (horizontal angle) for the equirectangular lens");
987 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
988
989 prop = RNA_def_property(srna, "longitude_max", PROP_FLOAT, PROP_ANGLE);
990 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
992 prop, "Max Longitude", "Maximum longitude (horizontal angle) for the equirectangular lens");
993 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
994
995 prop = RNA_def_property(srna, "fisheye_polynomial_k0", PROP_FLOAT, PROP_ANGLE);
997 RNA_def_property_ui_text(prop, "Fisheye Polynomial K0", "Coefficient K0 of the lens polynomial");
998 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
999
1000 prop = RNA_def_property(srna, "fisheye_polynomial_k1", PROP_FLOAT, PROP_ANGLE);
1001 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1002 RNA_def_property_ui_text(prop, "Fisheye Polynomial K1", "Coefficient K1 of the lens polynomial");
1003 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1004
1005 prop = RNA_def_property(srna, "fisheye_polynomial_k2", PROP_FLOAT, PROP_ANGLE);
1006 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1007 RNA_def_property_ui_text(prop, "Fisheye Polynomial K2", "Coefficient K2 of the lens polynomial");
1008 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1009
1010 prop = RNA_def_property(srna, "fisheye_polynomial_k3", PROP_FLOAT, PROP_ANGLE);
1011 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1012 RNA_def_property_ui_text(prop, "Fisheye Polynomial K3", "Coefficient K3 of the lens polynomial");
1013 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1014
1015 prop = RNA_def_property(srna, "fisheye_polynomial_k4", PROP_FLOAT, PROP_ANGLE);
1016 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 6);
1017 RNA_def_property_ui_text(prop, "Fisheye Polynomial K4", "Coefficient K4 of the lens polynomial");
1018 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1019
1020 prop = RNA_def_property(srna, "central_cylindrical_range_u_min", PROP_FLOAT, PROP_ANGLE);
1021 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
1023 prop, "Min Longitude", "Minimum Longitude value for the central cylindrical lens");
1024 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1025
1026 prop = RNA_def_property(srna, "central_cylindrical_range_u_max", PROP_FLOAT, PROP_ANGLE);
1027 RNA_def_property_ui_range(prop, -M_PI, M_PI, 3, 2);
1029 prop, "Max Longitude", "Maximum Longitude value for the central cylindrical lens");
1030 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1031
1032 prop = RNA_def_property(srna, "central_cylindrical_range_v_min", PROP_FLOAT, PROP_DISTANCE);
1033 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1f, 3);
1035 prop, "Min Height", "Minimum Height value for the central cylindrical lens");
1036 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1037
1038 prop = RNA_def_property(srna, "central_cylindrical_range_v_max", PROP_FLOAT, PROP_DISTANCE);
1039 RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.1f, 3);
1041 prop, "Max Height", "Maximum Height value for the central cylindrical lens");
1042 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1043
1044 prop = RNA_def_property(srna, "central_cylindrical_radius", PROP_FLOAT, PROP_DISTANCE);
1045 RNA_def_property_range(prop, 0.00001f, FLT_MAX);
1046 RNA_def_property_ui_range(prop, 0.00001f, 10.0f, 0.1f, 3);
1047 RNA_def_property_ui_text(prop, "Cylinder Radius", "Radius of the virtual cylinder");
1048 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1049
1050 /* Custom camera. */
1051 prop = RNA_def_property(srna, "custom_filepath", PROP_STRING, PROP_FILEPATH);
1053 prop, "Custom File Path", "Path to the shader defining the custom camera");
1054 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_custom_update");
1055
1056 prop = RNA_def_property(srna, "custom_shader", PROP_POINTER, PROP_NONE);
1057 RNA_def_property_struct_type(prop, "Text");
1059 RNA_def_property_ui_text(prop, "Custom Shader", "Shader defining the custom camera");
1060 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_custom_update");
1061
1062 prop = RNA_def_property(srna, "custom_mode", PROP_ENUM, PROP_NONE);
1063 RNA_def_property_enum_funcs(prop, nullptr, "rna_Camera_custom_mode_set", nullptr);
1064 RNA_def_property_enum_items(prop, custom_mode_items);
1065 RNA_def_property_ui_text(prop, "Custom shader source", "");
1066 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1067
1068 prop = RNA_def_property(srna, "custom_bytecode", PROP_STRING, PROP_NONE);
1070 "rna_Camera_custom_bytecode_get",
1071 "rna_Camera_custom_bytecode_length",
1072 "rna_Camera_custom_bytecode_set");
1073 RNA_def_property_ui_text(prop, "Custom Bytecode", "Compiled bytecode of the custom shader");
1074 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1075
1076 prop = RNA_def_property(srna, "custom_bytecode_hash", PROP_STRING, PROP_NONE);
1078 prop,
1079 "Custom Bytecode Hash",
1080 "Hash of the compiled bytecode of the custom shader, for quick equality checking");
1081 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
1082
1083 /* pointers */
1084 prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE);
1085 RNA_def_property_struct_type(prop, "CameraDOFSettings");
1086 RNA_def_property_ui_text(prop, "Depth Of Field", "");
1087 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
1088
1089 prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE);
1090 RNA_def_property_collection_sdna(prop, nullptr, "bg_images", nullptr);
1091 RNA_def_property_struct_type(prop, "CameraBackgroundImage");
1092 RNA_def_property_ui_text(prop, "Background Images", "List of background images");
1095 prop, nullptr, nullptr, "rna_Camera_background_images_override_apply");
1097
1099
1101
1104
1105 /* Nested Data. */
1107
1108 /* *** Animated *** */
1111
1112 /* Camera API */
1113 RNA_api_camera(srna);
1114}
1115
1116#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:361
const char * BKE_main_blendfile_path_from_global()
Definition main.cc:877
General operations, lookup, etc. for blender objects.
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#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 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:688
#define ELEM(...)
#define BLT_I18NCONTEXT_ID_CAMERA
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ LIBOVERRIDE_OP_INSERT_AFTER
Definition DNA_ID.h:230
@ ID_CA
@ CAM_S3D_PIVOT_CENTER
@ CAM_S3D_PIVOT_RIGHT
@ CAM_S3D_PIVOT_LEFT
@ 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_BGIMG_SOURCE_IMAGE
@ CAM_BGIMG_SOURCE_MOVIE
@ 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
@ 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_CUSTOM_SHADER_EXTERNAL
@ CAM_CUSTOM_SHADER_INTERNAL
@ CAM_S3D_SPHERICAL
@ CAM_S3D_POLE_MERGE
@ CAM_DOF_ENABLED
@ 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_S3D_PARALLEL
@ CAM_S3D_OFFAXIS
@ CAM_S3D_TOE
@ CAM_PERSP
@ CAM_PANO
@ CAM_CUSTOM
@ CAM_ORTHO
ParameterFlag
Definition RNA_types.hh:510
@ PARM_RNAPTR
Definition RNA_types.hh:513
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
#define RNA_TRANSLATION_PREC_DEFAULT
Definition RNA_types.hh:212
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:469
@ PROPOVERRIDE_LIBRARY_INSERTION
Definition RNA_types.hh:494
@ PROPOVERRIDE_NO_PROP_NAME
Definition RNA_types.hh:502
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:413
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:338
@ PROP_XYZ
Definition RNA_types.hh:257
@ PROP_DISTANCE
Definition RNA_types.hh:244
@ PROP_ANGLE
Definition RNA_types.hh:240
@ PROP_DISTANCE_CAMERA
Definition RNA_types.hh:245
@ PROP_NONE
Definition RNA_types.hh:221
@ PROP_FACTOR
Definition RNA_types.hh:239
@ PROP_FILEPATH
Definition RNA_types.hh:224
#define ND_SEQUENCER
Definition WM_types.hh:434
#define ND_DRAW
Definition WM_types.hh:458
#define NC_SCENE
Definition WM_types.hh:375
ReportList * reports
Definition WM_types.hh:1025
#define NC_CAMERA
Definition WM_types.hh:398
#define NC_OBJECT
Definition WM_types.hh:376
#define ND_DRAW_RENDER_VIEWPORT
Definition WM_types.hh:467
#define offsetof(t, d)
#define GS(a)
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_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:114
char * filepath
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4226