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