Blender V4.3
rna_object_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12#include <ctime>
13
14#include "BLI_kdopbvh.h"
15#include "BLI_math_geom.h"
16#include "BLI_utildefines.h"
17
18#include "RNA_define.hh"
19
21#include "DNA_layer_types.h"
22#include "DNA_modifier_types.h"
23#include "DNA_object_types.h"
24
26#include "BKE_layer.hh"
27
28#include "DEG_depsgraph.hh"
29
30#include "ED_outliner.hh"
31
32#include "rna_internal.hh" /* own include */
33
34#define MESH_DM_INFO_STR_MAX 16384
35
36static const EnumPropertyItem space_items[] = {
37 {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space", "The most global space in Blender"},
39 "POSE",
40 0,
41 "Pose Space",
42 "The pose space of a bone (its armature's object space)"},
44 "LOCAL_WITH_PARENT",
45 0,
46 "Local With Parent",
47 "The rest pose local space of a bone (this matrix includes parent transforms)"},
48 {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", "The local space of an object/bone"},
49 {0, nullptr, 0, nullptr, nullptr},
50};
51
52#ifdef RNA_RUNTIME
53
54# include "BKE_bvhutils.hh"
55# include "BKE_constraint.h"
56# include "BKE_context.hh"
57# include "BKE_crazyspace.hh"
58# include "BKE_customdata.hh"
59# include "BKE_global.hh"
60# include "BKE_layer.hh"
61# include "BKE_main.hh"
62# include "BKE_mball.hh"
63# include "BKE_mesh.hh"
64# include "BKE_mesh_runtime.hh"
65# include "BKE_modifier.hh"
66# include "BKE_object.hh"
67# include "BKE_object_types.hh"
68# include "BKE_report.hh"
69# include "BKE_vfont.hh"
70
71# include "ED_object.hh"
72# include "ED_screen.hh"
73
74# include "DNA_curve_types.h"
75# include "DNA_mesh_types.h"
76# include "DNA_scene_types.h"
77# include "DNA_view3d_types.h"
78
79# include "DEG_depsgraph_query.hh"
80
81# include "MEM_guardedalloc.h"
82
83static Base *find_view_layer_base_with_synced_ensure(
84 Object *ob, bContext *C, PointerRNA *view_layer_ptr, Scene **r_scene, ViewLayer **r_view_layer)
85{
86 Scene *scene;
87 ViewLayer *view_layer;
88 if (view_layer_ptr->data) {
89 scene = (Scene *)view_layer_ptr->owner_id;
90 view_layer = static_cast<ViewLayer *>(view_layer_ptr->data);
91 }
92 else {
93 scene = CTX_data_scene(C);
94 view_layer = CTX_data_view_layer(C);
95 }
96 if (r_scene != nullptr) {
97 *r_scene = scene;
98 }
99 if (r_view_layer != nullptr) {
100 *r_view_layer = view_layer;
101 }
102
103 BKE_view_layer_synced_ensure(scene, view_layer);
104 return BKE_view_layer_base_find(view_layer, ob);
105}
106
107static void rna_Object_select_set(
108 Object *ob, bContext *C, ReportList *reports, bool select, PointerRNA *view_layer_ptr)
109{
110 Scene *scene;
111 ViewLayer *view_layer;
112 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, &scene, &view_layer);
113
114 if (!base) {
115 if (select) {
116 BKE_reportf(reports,
117 RPT_ERROR,
118 "Object '%s' can't be selected because it is not in View Layer '%s'!",
119 ob->id.name + 2,
120 view_layer->name);
121 }
122 return;
123 }
124
127
131}
132
133static bool rna_Object_select_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr)
134{
135 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, nullptr, nullptr);
136 if (!base) {
137 return false;
138 }
139
140 return ((base->flag & BASE_SELECTED) != 0);
141}
142
143static void rna_Object_hide_set(
144 Object *ob, bContext *C, ReportList *reports, bool hide, PointerRNA *view_layer_ptr)
145{
146 Scene *scene;
147 ViewLayer *view_layer;
148 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, &scene, &view_layer);
149 if (!base) {
150 if (hide) {
151 BKE_reportf(reports,
152 RPT_ERROR,
153 "Object '%s' can't be hidden because it is not in View Layer '%s'!",
154 ob->id.name + 2,
155 view_layer->name);
156 }
157 return;
158 }
159
160 if (hide) {
161 base->flag |= BASE_HIDDEN;
162 }
163 else {
164 base->flag &= ~BASE_HIDDEN;
165 }
166
170}
171
172static bool rna_Object_hide_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr)
173{
174 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, nullptr, nullptr);
175 if (!base) {
176 return false;
177 }
178
179 return ((base->flag & BASE_HIDDEN) != 0);
180}
181
182static bool rna_Object_visible_get(Object *ob,
183 bContext *C,
184 PointerRNA *view_layer_ptr,
185 View3D *v3d)
186{
187 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, nullptr, nullptr);
188 if (v3d == nullptr) {
189 v3d = CTX_wm_view3d(C);
190 }
191
192 if (!base) {
193 return false;
194 }
195
196 return BASE_VISIBLE(v3d, base);
197}
198
199static bool rna_Object_holdout_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr)
200{
201 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, nullptr, nullptr);
202 if (!base) {
203 return false;
204 }
205
206 return ((base->flag & BASE_HOLDOUT) != 0) || ((ob->visibility_flag & OB_HOLDOUT) != 0);
207}
208
209static bool rna_Object_indirect_only_get(Object *ob, bContext *C, PointerRNA *view_layer_ptr)
210{
211 Base *base = find_view_layer_base_with_synced_ensure(ob, C, view_layer_ptr, nullptr, nullptr);
212 if (!base) {
213 return false;
214 }
215
216 return ((base->flag & BASE_INDIRECT_ONLY) != 0);
217}
218
219static Base *rna_Object_local_view_property_helper(bScreen *screen,
220 View3D *v3d,
221 ViewLayer *view_layer,
222 Object *ob,
223 ReportList *reports,
224 Scene **r_scene)
225{
226 wmWindow *win = nullptr;
227 if (v3d->localvd == nullptr) {
228 BKE_report(reports, RPT_ERROR, "Viewport not in local view");
229 return nullptr;
230 }
231
232 if (view_layer == nullptr) {
233 win = ED_screen_window_find(screen, static_cast<wmWindowManager *>(G_MAIN->wm.first));
234 view_layer = WM_window_get_active_view_layer(win);
235 }
236
237 BKE_view_layer_synced_ensure(win ? WM_window_get_active_scene(win) : nullptr, view_layer);
238 Base *base = BKE_view_layer_base_find(view_layer, ob);
239 if (base == nullptr) {
241 reports, RPT_WARNING, "Object %s not in view layer %s", ob->id.name + 2, view_layer->name);
242 }
243 if (r_scene != nullptr && win != nullptr) {
244 *r_scene = win->scene;
245 }
246 return base;
247}
248
249static bool rna_Object_local_view_get(Object *ob, ReportList *reports, View3D *v3d)
250{
251 if (v3d->localvd == nullptr) {
252 BKE_report(reports, RPT_ERROR, "Viewport not in local view");
253 return false;
254 }
255
256 return ((ob->base_local_view_bits & v3d->local_view_uid) != 0);
257}
258
259static void rna_Object_local_view_set(Object *ob,
260 ReportList *reports,
261 PointerRNA *v3d_ptr,
262 bool state)
263{
264 bScreen *screen = (bScreen *)v3d_ptr->owner_id;
265 View3D *v3d = static_cast<View3D *>(v3d_ptr->data);
266 Scene *scene;
267 Base *base = rna_Object_local_view_property_helper(screen, v3d, nullptr, ob, reports, &scene);
268 if (base == nullptr) {
269 return; /* Error reported. */
270 }
271 const short local_view_bits_prev = base->local_view_bits;
273 if (local_view_bits_prev != base->local_view_bits) {
275 ScrArea *area = ED_screen_area_find_with_spacedata(screen, (SpaceLink *)v3d, true);
276 if (area) {
277 ED_area_tag_redraw(area);
278 }
279 }
280}
281
282static bool rna_Object_visible_in_viewport_get(Object *ob, View3D *v3d)
283{
284 return BKE_object_is_visible_in_viewport(v3d, ob);
285}
286
287/* Convert a given matrix from a space to another (using the object and/or a bone as
288 * reference). */
289static void rna_Object_mat_convert_space(Object *ob,
290 ReportList *reports,
291 bPoseChannel *pchan,
292 const float mat[16],
293 float mat_ret[16],
294 int from,
295 int to)
296{
297 copy_m4_m4((float(*)[4])mat_ret, (float(*)[4])mat);
298
301
302 /* Error in case of invalid from/to values when pchan is nullptr */
303 if (pchan == nullptr) {
305 const char *identifier = nullptr;
306 RNA_enum_identifier(space_items, from, &identifier);
307 BKE_reportf(reports,
308 RPT_ERROR,
309 "'from_space' '%s' is invalid when no pose bone is given!",
310 identifier);
311 return;
312 }
314 const char *identifier = nullptr;
315 RNA_enum_identifier(space_items, to, &identifier);
316 BKE_reportf(reports,
317 RPT_ERROR,
318 "'to_space' '%s' is invalid when no pose bone is given!",
319 identifier);
320 return;
321 }
322 }
323 /* These checks are extra security, they should never occur. */
324 if (from == CONSTRAINT_SPACE_CUSTOM) {
325 const char *identifier = nullptr;
326 RNA_enum_identifier(space_items, from, &identifier);
327 BKE_reportf(reports,
328 RPT_ERROR,
329 "'from_space' '%s' is invalid when no custom space is given!",
330 identifier);
331 return;
332 }
333 if (to == CONSTRAINT_SPACE_CUSTOM) {
334 const char *identifier = nullptr;
335 RNA_enum_identifier(space_items, to, &identifier);
336 BKE_reportf(reports,
337 RPT_ERROR,
338 "'to_space' '%s' is invalid when no custom space is given!",
339 identifier);
340 return;
341 }
342
343 BKE_constraint_mat_convertspace(ob, pchan, nullptr, (float(*)[4])mat_ret, from, to, false);
344}
345
346static void rna_Object_calc_matrix_camera(Object *ob,
347 Depsgraph *depsgraph,
348 float mat_ret[16],
349 int width,
350 int height,
351 float scalex,
352 float scaley)
353{
354 const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
356
357 /* setup parameters */
360
361 /* Compute matrix, view-plane, etc. */
362 BKE_camera_params_compute_viewplane(&params, width, height, scalex, scaley);
364
365 copy_m4_m4((float(*)[4])mat_ret, params.winmat);
366}
367
368static void rna_Object_camera_fit_coords(Object *ob,
369 Depsgraph *depsgraph,
370 const float *cos,
371 int cos_num,
372 float co_ret[3],
373 float *scale_ret)
374{
376 depsgraph, (const float(*)[3])cos, cos_num / 3, ob, co_ret, scale_ret);
377}
378
379static void rna_Object_crazyspace_eval(Object *object,
380 ReportList *reports,
381 Depsgraph *depsgraph,
382 Scene *scene)
383{
384 BKE_crazyspace_api_eval(depsgraph, scene, object, reports);
385}
386
387static void rna_Object_crazyspace_displacement_to_deformed(Object *object,
388 ReportList *reports,
389 const int vertex_index,
390 const float displacement[3],
391 float r_displacement_deformed[3])
392{
394 object, reports, vertex_index, displacement, r_displacement_deformed);
395}
396
397static void rna_Object_crazyspace_displacement_to_original(Object *object,
398 ReportList *reports,
399 const int vertex_index,
400 const float displacement_deformed[3],
401 float r_displacement[3])
402{
404 object, reports, vertex_index, displacement_deformed, r_displacement);
405}
406
407static void rna_Object_crazyspace_eval_clear(Object *object)
408{
410}
411
412/* copied from Mesh_getFromObject and adapted to RNA interface */
413static Mesh *rna_Object_to_mesh(Object *object,
414 ReportList *reports,
415 bool preserve_all_data_layers,
416 Depsgraph *depsgraph)
417{
418 /* TODO(sergey): Make it more re-usable function, de-duplicate with
419 * rna_Main_meshes_new_from_object. */
420 switch (object->type) {
421 case OB_FONT:
422 case OB_CURVES_LEGACY:
423 case OB_SURF:
424 case OB_MBALL:
425 case OB_MESH:
426 break;
427 default:
428 BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
429 return nullptr;
430 }
431
432 return BKE_object_to_mesh(depsgraph, object, preserve_all_data_layers);
433}
434
435static void rna_Object_to_mesh_clear(Object *object)
436{
438}
439
440static Curve *rna_Object_to_curve(Object *object,
441 ReportList *reports,
442 Depsgraph *depsgraph,
443 bool apply_modifiers)
444{
445 if (!ELEM(object->type, OB_FONT, OB_CURVES_LEGACY)) {
446 BKE_report(reports, RPT_ERROR, "Object is not a curve or a text");
447 return nullptr;
448 }
449
450 if (depsgraph == nullptr) {
451 BKE_report(reports, RPT_ERROR, "Invalid depsgraph");
452 return nullptr;
453 }
454
455 return BKE_object_to_curve(object, depsgraph, apply_modifiers);
456}
457
458static void rna_Object_to_curve_clear(Object *object)
459{
461}
462
463static PointerRNA rna_Object_shape_key_add(
464 Object *ob, bContext *C, ReportList *reports, const char *name, bool from_mix)
465{
466 Main *bmain = CTX_data_main(C);
467 KeyBlock *kb = nullptr;
468
469 if ((kb = BKE_object_shapekey_insert(bmain, ob, name, from_mix))) {
470 PointerRNA keyptr = RNA_pointer_create((ID *)BKE_key_from_object(ob), &RNA_ShapeKey, kb);
472
475
476 return keyptr;
477 }
478 else {
479 BKE_reportf(reports, RPT_ERROR, "Object '%s' does not support shapes", ob->id.name + 2);
480 return PointerRNA_NULL;
481 }
482}
483
484static void rna_Object_shape_key_remove(Object *ob,
485 Main *bmain,
486 ReportList *reports,
487 PointerRNA *kb_ptr)
488{
489 KeyBlock *kb = static_cast<KeyBlock *>(kb_ptr->data);
490 Key *key = BKE_key_from_object(ob);
491
492 if ((key == nullptr) || BLI_findindex(&key->block, kb) == -1) {
493 BKE_report(reports, RPT_ERROR, "ShapeKey not found");
494 return;
495 }
496
497 if (!BKE_object_shapekey_remove(bmain, ob, kb)) {
498 BKE_report(reports, RPT_ERROR, "Could not remove ShapeKey");
499 return;
500 }
501
504
506}
507
508static void rna_Object_shape_key_clear(Object *ob, Main *bmain)
509{
510 BKE_object_shapekey_free(bmain, ob);
511
514}
515
516# if 0
517static void rna_Mesh_assign_verts_to_group(
518 Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
519{
520 if (ob->type != OB_MESH) {
521 BKE_report(reports, RPT_ERROR, "Object should be of mesh type");
522 return;
523 }
524
525 Mesh *mesh = (Mesh *)ob->data;
526 int group_index = BLI_findlink(&ob->defbase, group);
527 if (group_index == -1) {
528 BKE_report(reports, RPT_ERROR, "No vertex groups assigned to mesh");
529 return;
530 }
531
532 if (assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD && assignmode != WEIGHT_SUBTRACT) {
533 BKE_report(reports, RPT_ERROR, "Bad assignment mode");
534 return;
535 }
536
537 /* makes a set of dVerts corresponding to the mVerts */
538 if (!mesh->dvert) {
539 create_dverts(&mesh->id);
540 }
541
542 /* Loop list adding verts to group. */
543 for (i = 0; i < totindex; i++) {
544 if (i < 0 || i >= mesh->verts_num) {
545 BKE_report(reports, RPT_ERROR, "Bad vertex index in list");
546 return;
547 }
548
549 add_vert_defnr(ob, group_index, i, weight, assignmode);
550 }
551}
552# endif
553
554/* don't call inside a loop */
555static int mesh_corner_tri_to_face_index(Mesh *mesh_eval, const int tri_index)
556{
557 const blender::Span<int> tri_faces = mesh_eval->corner_tri_faces();
558 const int face_i = tri_faces[tri_index];
559 const int *index_face_to_orig = static_cast<const int *>(
561 return index_face_to_orig ? index_face_to_orig[face_i] : face_i;
562}
563
564/* TODO(sergey): Make the Python API more clear that evaluation might happen, or require
565 * passing fully evaluated depsgraph. */
566static Object *eval_object_ensure(Object *ob,
567 bContext *C,
568 ReportList *reports,
569 PointerRNA *rnaptr_depsgraph)
570{
571 if (ob->runtime->data_eval == nullptr) {
572 Object *ob_orig = ob;
573 Depsgraph *depsgraph = rnaptr_depsgraph != nullptr ?
574 static_cast<Depsgraph *>(rnaptr_depsgraph->data) :
575 nullptr;
576 if (depsgraph == nullptr) {
578 }
579 if (depsgraph != nullptr) {
581 }
582 if (ob == nullptr || BKE_object_get_evaluated_mesh(ob) == nullptr) {
584 reports, RPT_ERROR, "Object '%s' has no evaluated mesh data", ob_orig->id.name + 2);
585 return nullptr;
586 }
587 }
588 return ob;
589}
590
591static void rna_Object_ray_cast(Object *ob,
592 bContext *C,
593 ReportList *reports,
594 const float origin[3],
595 const float direction[3],
596 float distance,
597 PointerRNA *rnaptr_depsgraph,
598 bool *r_success,
599 float r_location[3],
600 float r_normal[3],
601 int *r_index)
602{
603 bool success = false;
604
605 /* TODO(sergey): This isn't very reliable check. It is possible to have non-nullptr pointer
606 * but which is out of date, and possibly dangling one. */
607 if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == nullptr) {
608 return;
609 }
610
611 Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
612
613 /* Test bounding box first (efficiency) */
614 const std::optional<blender::Bounds<blender::float3>> bounds = mesh_eval->bounds_min_max();
615 if (!bounds) {
616 return;
617 }
618 float distmin;
619
620 /* Needed for valid distance check from #isect_ray_aabb_v3_simple() call. */
621 float direction_unit[3];
622 normalize_v3_v3(direction_unit, direction);
623
625 origin, direction_unit, bounds->min, bounds->max, &distmin, nullptr) &&
626 distmin <= distance))
627 {
628 BVHTreeFromMesh treeData = {nullptr};
629
630 /* No need to managing allocation or freeing of the BVH data.
631 * This is generated and freed as needed. */
632 BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_CORNER_TRIS, 4);
633
634 /* may fail if the mesh has no faces, in that case the ray-cast misses */
635 if (treeData.tree != nullptr) {
636 BVHTreeRayHit hit;
637
638 hit.index = -1;
639 hit.dist = distance;
640
641 if (BLI_bvhtree_ray_cast(treeData.tree,
642 origin,
643 direction_unit,
644 0.0f,
645 &hit,
646 treeData.raycast_callback,
647 &treeData) != -1)
648 {
649 if (hit.dist <= distance) {
650 *r_success = success = true;
651
652 copy_v3_v3(r_location, hit.co);
653 copy_v3_v3(r_normal, hit.no);
654 *r_index = mesh_corner_tri_to_face_index(mesh_eval, hit.index);
655 }
656 }
657
658 free_bvhtree_from_mesh(&treeData);
659 }
660 }
661 if (success == false) {
662 *r_success = false;
663
664 zero_v3(r_location);
665 zero_v3(r_normal);
666 *r_index = -1;
667 }
668}
669
670static void rna_Object_closest_point_on_mesh(Object *ob,
671 bContext *C,
672 ReportList *reports,
673 const float origin[3],
674 float distance,
675 PointerRNA *rnaptr_depsgraph,
676 bool *r_success,
677 float r_location[3],
678 float r_normal[3],
679 int *r_index)
680{
681 BVHTreeFromMesh treeData = {nullptr};
682
683 if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == nullptr) {
684 return;
685 }
686
687 /* No need to managing allocation or freeing of the BVH data.
688 * this is generated and freed as needed. */
689 Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
690 BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_CORNER_TRIS, 4);
691
692 if (treeData.tree == nullptr) {
693 BKE_reportf(reports,
694 RPT_ERROR,
695 "Object '%s' could not create internal data for finding nearest point",
696 ob->id.name + 2);
697 return;
698 }
699 else {
700 BVHTreeNearest nearest;
701
702 nearest.index = -1;
703 nearest.dist_sq = distance * distance;
704
706 treeData.tree, origin, &nearest, treeData.nearest_callback, &treeData) != -1)
707 {
708 *r_success = true;
709
710 copy_v3_v3(r_location, nearest.co);
711 copy_v3_v3(r_normal, nearest.no);
712 *r_index = mesh_corner_tri_to_face_index(mesh_eval, nearest.index);
713
714 goto finally;
715 }
716 }
717
718 *r_success = false;
719
720 zero_v3(r_location);
721 zero_v3(r_normal);
722 *r_index = -1;
723
724finally:
725 free_bvhtree_from_mesh(&treeData);
726}
727
728static bool rna_Object_is_modified(Object *ob, Scene *scene, int settings)
729{
730 return BKE_object_is_modified(scene, ob) & settings;
731}
732
733static bool rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
734{
735 return BKE_object_is_deform_modified(scene, ob) & settings;
736}
737
738# ifndef NDEBUG
739
740# include "BKE_mesh_runtime.hh"
741
742void rna_Object_me_eval_info(
743 Object *ob, bContext *C, int type, PointerRNA *rnaptr_depsgraph, char *result)
744{
745 const Mesh *mesh_eval = nullptr;
746 char *ret = nullptr;
747
748 result[0] = '\0';
749
750 switch (type) {
751 case 1:
752 case 2:
753 if ((ob = eval_object_ensure(ob, C, nullptr, rnaptr_depsgraph)) == nullptr) {
754 return;
755 }
756 }
757
758 switch (type) {
759 case 0:
760 if (ob->type == OB_MESH) {
761 mesh_eval = static_cast<Mesh *>(ob->data);
762 }
763 break;
764 case 1:
765 mesh_eval = BKE_object_get_mesh_deform_eval(ob);
766 break;
767 case 2:
768 mesh_eval = BKE_object_get_evaluated_mesh(ob);
769 break;
770 }
771
772 if (mesh_eval) {
773 ret = BKE_mesh_debug_info(mesh_eval);
774 if (ret) {
776 MEM_freeN(ret);
777 }
778 }
779}
780# else
781void rna_Object_me_eval_info(Object * /*ob*/,
782 bContext * /*C*/,
783 int /*type*/,
784 PointerRNA * /*rnaptr_depsgraph*/,
785 char *result)
786{
787 result[0] = '\0';
788}
789# endif /* NDEBUG */
790
791static bool rna_Object_update_from_editmode(Object *ob, Main *bmain)
792{
793 /* fail gracefully if we aren't in edit-mode. */
794 const bool result = blender::ed::object::editmode_load(bmain, ob);
795 if (result) {
796 /* Loading edit mesh to mesh changes geometry, and scripts might expect it to be properly
797 * informed about changes. */
799 }
800 return result;
801}
802
803#else /* RNA_RUNTIME */
804
806{
807 FunctionRNA *func;
808 PropertyRNA *parm;
809
810 static const EnumPropertyItem mesh_type_items[] = {
811 {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"},
812 {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"},
813 {0, nullptr, 0, nullptr, nullptr},
814 };
815
816# ifndef NDEBUG
817 static const EnumPropertyItem mesh_dm_info_items[] = {
818 {0, "SOURCE", 0, "Source", "Source mesh"},
819 {1, "DEFORM", 0, "Deform", "Objects deform mesh"},
820 {2, "FINAL", 0, "Final", "Objects final mesh"},
821 {0, nullptr, 0, nullptr, nullptr},
822 };
823# endif
824
825 /* Special wrapper to access the base selection value */
826 func = RNA_def_function(srna, "select_get", "rna_Object_select_get");
828 func, "Test if the object is selected. The selection state is per view layer.");
830 parm = RNA_def_pointer(
831 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
833 parm = RNA_def_boolean(func, "result", false, "", "Object selected");
834 RNA_def_function_return(func, parm);
835
836 func = RNA_def_function(srna, "select_set", "rna_Object_select_set");
838 func, "Select or deselect the object. The selection state is per view layer.");
840 parm = RNA_def_boolean(func, "state", false, "", "Selection state to define");
842 parm = RNA_def_pointer(
843 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
845
846 func = RNA_def_function(srna, "hide_get", "rna_Object_hide_get");
848 func,
849 "Test if the object is hidden for viewport editing. This hiding state is per view layer.");
851 parm = RNA_def_pointer(
852 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
854 parm = RNA_def_boolean(func, "result", false, "", "Object hidden");
855 RNA_def_function_return(func, parm);
856
857 func = RNA_def_function(srna, "hide_set", "rna_Object_hide_set");
859 func, "Hide the object for viewport editing. This hiding state is per view layer.");
861 parm = RNA_def_boolean(func, "state", false, "", "Hide state to define");
863 parm = RNA_def_pointer(
864 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
866
867 func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get");
869 "Test if the object is visible in the 3D viewport, taking into "
870 "account all visibility settings");
872 parm = RNA_def_pointer(
873 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
875 parm = RNA_def_pointer(
876 func, "viewport", "SpaceView3D", "", "Use this instead of the active 3D viewport");
877 parm = RNA_def_boolean(func, "result", false, "", "Object visible");
878 RNA_def_function_return(func, parm);
879
880 func = RNA_def_function(srna, "holdout_get", "rna_Object_holdout_get");
881 RNA_def_function_ui_description(func, "Test if object is masked in the view layer");
883 parm = RNA_def_pointer(
884 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
886 parm = RNA_def_boolean(func, "result", false, "", "Object holdout");
887 RNA_def_function_return(func, parm);
888
889 func = RNA_def_function(srna, "indirect_only_get", "rna_Object_indirect_only_get");
891 "Test if object is set to contribute only indirectly (through "
892 "shadows and reflections) in the view layer");
894 parm = RNA_def_pointer(
895 func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
897 parm = RNA_def_boolean(func, "result", false, "", "Object indirect only");
898 RNA_def_function_return(func, parm);
899
900 /* Local View */
901 func = RNA_def_function(srna, "local_view_get", "rna_Object_local_view_get");
902 RNA_def_function_ui_description(func, "Get the local view state for this object");
904 parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
906 parm = RNA_def_boolean(func, "result", false, "", "Object local view state");
907 RNA_def_function_return(func, parm);
908
909 func = RNA_def_function(srna, "local_view_set", "rna_Object_local_view_set");
910 RNA_def_function_ui_description(func, "Set the local view state for this object");
912 parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
914 parm = RNA_def_boolean(func, "state", false, "", "Local view state to define");
916
917 /* Viewport */
918 func = RNA_def_function(srna, "visible_in_viewport_get", "rna_Object_visible_in_viewport_get");
920 func, "Check for local view and local collections for this viewport and object");
921 parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local collections");
923 parm = RNA_def_boolean(func, "result", false, "", "Object viewport visibility");
924 RNA_def_function_return(func, parm);
925
926 /* Matrix space conversion */
927 func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space");
929 func, "Convert (transform) the given matrix from one space to another");
931 parm = RNA_def_pointer(
932 func,
933 "pose_bone",
934 "PoseBone",
935 "",
936 "Bone to use to define spaces (may be None, in which case only the two 'WORLD' and "
937 "'LOCAL' spaces are usable)");
938 parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
940 RNA_def_property_ui_text(parm, "", "The matrix to transform");
941 parm = RNA_def_property(func, "matrix_return", PROP_FLOAT, PROP_MATRIX);
943 RNA_def_property_ui_text(parm, "", "The transformed matrix");
944 RNA_def_function_output(func, parm);
945 parm = RNA_def_enum(func,
946 "from_space",
949 "",
950 "The space in which 'matrix' is currently");
951 parm = RNA_def_enum(func,
952 "to_space",
955 "",
956 "The space to which you want to transform 'matrix'");
957
958 /* Camera-related operations */
959 func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera");
961 "Generate the camera projection matrix of this object "
962 "(mostly useful for Camera and Light types)");
963 parm = RNA_def_pointer(
964 func, "depsgraph", "Depsgraph", "", "Depsgraph to get evaluated data from");
966 parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX);
968 RNA_def_property_ui_text(parm, "", "The camera projection matrix");
969 RNA_def_function_output(func, parm);
970 parm = RNA_def_int(func, "x", 1, 0, INT_MAX, "", "Width of the render area", 0, 10000);
971 parm = RNA_def_int(func, "y", 1, 0, INT_MAX, "", "Height of the render area", 0, 10000);
972 parm = RNA_def_float(
973 func, "scale_x", 1.0f, 1.0e-6f, FLT_MAX, "", "Width scaling factor", 1.0e-2f, 100.0f);
974 parm = RNA_def_float(
975 func, "scale_y", 1.0f, 1.0e-6f, FLT_MAX, "", "Height scaling factor", 1.0e-2f, 100.0f);
976
977 func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords");
979 "Compute the coordinate (and scale for ortho cameras) "
980 "given object should be to 'see' all given coordinates");
981 parm = RNA_def_pointer(
982 func, "depsgraph", "Depsgraph", "", "Depsgraph to get evaluated data from");
984 parm = RNA_def_float_array(func,
985 "coordinates",
986 1,
987 nullptr,
988 -FLT_MAX,
989 FLT_MAX,
990 "",
991 "Coordinates to fit in",
992 -FLT_MAX,
993 FLT_MAX);
995 parm = RNA_def_property(func, "co_return", PROP_FLOAT, PROP_XYZ);
996 RNA_def_property_array(parm, 3);
997 RNA_def_property_ui_text(parm, "", "The location to aim to be able to see all given points");
999 parm = RNA_def_property(func, "scale_return", PROP_FLOAT, PROP_NONE);
1001 parm, "", "The ortho scale to aim to be able to see all given points (if relevant)");
1003
1004 /* Crazy-space access. */
1005
1006 func = RNA_def_function(srna, "crazyspace_eval", "rna_Object_crazyspace_eval");
1008 func,
1009 "Compute orientation mapping between vertices of an original object and object with shape "
1010 "keys and deforming modifiers applied."
1011 "The evaluation is to be freed with the crazyspace_eval_free function");
1013 parm = RNA_def_pointer(
1014 func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph");
1016 parm = RNA_def_pointer(func, "scene", "Scene", "Scene", "Scene of the object");
1018
1019 func = RNA_def_function(srna,
1020 "crazyspace_displacement_to_deformed",
1021 "rna_Object_crazyspace_displacement_to_deformed");
1023 func, "Convert displacement vector from non-deformed object space to deformed object space");
1025 RNA_def_property(func, "vertex_index", PROP_INT, PROP_NONE);
1027 parm = RNA_def_property(func, "displacement", PROP_FLOAT, PROP_XYZ);
1028 RNA_def_property_array(parm, 3);
1029 parm = RNA_def_property(func, "displacement_deformed", PROP_FLOAT, PROP_XYZ);
1030 RNA_def_property_array(parm, 3);
1031 RNA_def_function_output(func, parm);
1032
1033 func = RNA_def_function(srna,
1034 "crazyspace_displacement_to_original",
1035 "rna_Object_crazyspace_displacement_to_original");
1037 func, "Convert displacement vector from deformed object space to non-deformed object space");
1039 RNA_def_property(func, "vertex_index", PROP_INT, PROP_NONE);
1041 parm = RNA_def_property(func, "displacement", PROP_FLOAT, PROP_XYZ);
1042 RNA_def_property_array(parm, 3);
1043 parm = RNA_def_property(func, "displacement_original", PROP_FLOAT, PROP_XYZ);
1044 RNA_def_property_array(parm, 3);
1045 RNA_def_function_output(func, parm);
1046
1047 RNA_def_function(srna, "crazyspace_eval_clear", "rna_Object_crazyspace_eval_clear");
1048 RNA_def_function_ui_description(func, "Free evaluated state of crazyspace");
1049
1050 /* mesh */
1051 func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
1053 func,
1054 "Create a Mesh data-block from the current state of the object. The object owns the "
1055 "data-block. To force free it use to_mesh_clear(). "
1056 "The result is temporary and cannot be used by objects from the main database.");
1058 RNA_def_boolean(func,
1059 "preserve_all_data_layers",
1060 false,
1061 "",
1062 "Preserve all data layers in the mesh, like UV maps and vertex groups. "
1063 "By default Blender only computes the subset of data layers needed for viewport "
1064 "display and rendering, for better performance.");
1066 func,
1067 "depsgraph",
1068 "Depsgraph",
1069 "Dependency Graph",
1070 "Evaluated dependency graph which is required when preserve_all_data_layers is true");
1071 parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object");
1072 RNA_def_function_return(func, parm);
1073
1074 func = RNA_def_function(srna, "to_mesh_clear", "rna_Object_to_mesh_clear");
1075 RNA_def_function_ui_description(func, "Clears mesh data-block created by to_mesh()");
1076
1077 /* curve */
1078 func = RNA_def_function(srna, "to_curve", "rna_Object_to_curve");
1080 func,
1081 "Create a Curve data-block from the current state of the object. This only works for curve "
1082 "and text objects. The object owns the data-block. To force free it, use to_curve_clear(). "
1083 "The result is temporary and cannot be used by objects from the main database.");
1085 parm = RNA_def_pointer(
1086 func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph");
1088 RNA_def_boolean(func,
1089 "apply_modifiers",
1090 false,
1091 "",
1092 "Apply the deform modifiers on the control points of the curve. This is only "
1093 "supported for curve objects.");
1094 parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve created from object");
1095 RNA_def_function_return(func, parm);
1096
1097 func = RNA_def_function(srna, "to_curve_clear", "rna_Object_to_curve_clear");
1098 RNA_def_function_ui_description(func, "Clears curve data-block created by to_curve()");
1099
1100 /* Armature */
1101 func = RNA_def_function(srna, "find_armature", "BKE_modifiers_is_deformed_by_armature");
1103 func, "Find armature influencing this object as a parent or via a modifier");
1104 parm = RNA_def_pointer(
1105 func, "ob_arm", "Object", "", "Armature object influencing this object or nullptr");
1106 RNA_def_function_return(func, parm);
1107
1108 /* Shape key */
1109 func = RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add");
1110 RNA_def_function_ui_description(func, "Add shape key to this object");
1112 RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keyblock"); /* optional */
1113 RNA_def_boolean(func, "from_mix", true, "", "Create new shape from existing mix of shapes");
1114 parm = RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock");
1116 RNA_def_function_return(func, parm);
1117
1118 func = RNA_def_function(srna, "shape_key_remove", "rna_Object_shape_key_remove");
1119 RNA_def_function_ui_description(func, "Remove a Shape Key from this object");
1121 parm = RNA_def_pointer(func, "key", "ShapeKey", "", "Keyblock to be removed");
1124
1125 func = RNA_def_function(srna, "shape_key_clear", "rna_Object_shape_key_clear");
1126 RNA_def_function_ui_description(func, "Remove all Shape Keys from this object");
1128
1129 /* Ray Cast */
1130 func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
1132 func,
1133 "Cast a ray onto evaluated geometry, in object space "
1134 "(using context's or provided depsgraph to get evaluated mesh if needed)");
1136
1137 /* ray start and end */
1138 parm = RNA_def_float_vector(func,
1139 "origin",
1140 3,
1141 nullptr,
1142 -FLT_MAX,
1143 FLT_MAX,
1144 "",
1145 "Origin of the ray, in object space",
1146 -1e4,
1147 1e4);
1149 parm = RNA_def_float_vector(func,
1150 "direction",
1151 3,
1152 nullptr,
1153 -FLT_MAX,
1154 FLT_MAX,
1155 "",
1156 "Direction of the ray, in object space",
1157 -1e4,
1158 1e4);
1160 RNA_def_float(func,
1161 "distance",
1163 0.0,
1165 "",
1166 "Maximum distance",
1167 0.0,
1169 parm = RNA_def_pointer(
1170 func,
1171 "depsgraph",
1172 "Depsgraph",
1173 "",
1174 "Depsgraph to use to get evaluated data, when called from original object "
1175 "(only needed if current Context's depsgraph is not suitable)");
1177
1178 /* return location and normal */
1179 parm = RNA_def_boolean(
1180 func, "result", false, "", "Whether the ray successfully hit the geometry");
1181 RNA_def_function_output(func, parm);
1182 parm = RNA_def_float_vector(func,
1183 "location",
1184 3,
1185 nullptr,
1186 -FLT_MAX,
1187 FLT_MAX,
1188 "Location",
1189 "The hit location of this ray cast",
1190 -1e4,
1191 1e4);
1193 RNA_def_function_output(func, parm);
1194 parm = RNA_def_float_vector(func,
1195 "normal",
1196 3,
1197 nullptr,
1198 -FLT_MAX,
1199 FLT_MAX,
1200 "Normal",
1201 "The face normal at the ray cast hit location",
1202 -1e4,
1203 1e4);
1205 RNA_def_function_output(func, parm);
1206 parm = RNA_def_int(
1207 func, "index", 0, 0, 0, "", "The face index, -1 when original data isn't available", 0, 0);
1208 RNA_def_function_output(func, parm);
1209
1210 /* Nearest Point */
1211 func = RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh");
1213 func,
1214 "Find the nearest point on evaluated geometry, in object space "
1215 "(using context's or provided depsgraph to get evaluated mesh if needed)");
1217
1218 /* location of point for test and max distance */
1219 parm = RNA_def_float_vector(func,
1220 "origin",
1221 3,
1222 nullptr,
1223 -FLT_MAX,
1224 FLT_MAX,
1225 "",
1226 "Point to find closest geometry from (in object space)",
1227 -1e4,
1228 1e4);
1230 /* default is sqrt(FLT_MAX) */
1232 func, "distance", 1.844674352395373e+19, 0.0, FLT_MAX, "", "Maximum distance", 0.0, FLT_MAX);
1233 parm = RNA_def_pointer(
1234 func,
1235 "depsgraph",
1236 "Depsgraph",
1237 "",
1238 "Depsgraph to use to get evaluated data, when called from original object "
1239 "(only needed if current Context's depsgraph is not suitable)");
1241
1242 /* return location and normal */
1243 parm = RNA_def_boolean(func, "result", false, "", "Whether closest point on geometry was found");
1244 RNA_def_function_output(func, parm);
1245 parm = RNA_def_float_vector(func,
1246 "location",
1247 3,
1248 nullptr,
1249 -FLT_MAX,
1250 FLT_MAX,
1251 "Location",
1252 "The location on the object closest to the point",
1253 -1e4,
1254 1e4);
1256 RNA_def_function_output(func, parm);
1257 parm = RNA_def_float_vector(func,
1258 "normal",
1259 3,
1260 nullptr,
1261 -FLT_MAX,
1262 FLT_MAX,
1263 "Normal",
1264 "The face normal at the closest point",
1265 -1e4,
1266 1e4);
1268 RNA_def_function_output(func, parm);
1269
1270 parm = RNA_def_int(
1271 func, "index", 0, 0, 0, "", "The face index, -1 when original data isn't available", 0, 0);
1272 RNA_def_function_output(func, parm);
1273
1274 /* View */
1275
1276 /* utility function for checking if the object is modified */
1277 func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified");
1279 "Determine if this object is modified from the base mesh data");
1280 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene in which to check the object");
1282 parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
1284 parm = RNA_def_boolean(func, "result", false, "", "Whether the object is modified");
1285 RNA_def_function_return(func, parm);
1286
1287 func = RNA_def_function(srna, "is_deform_modified", "rna_Object_is_deform_modified");
1289 func, "Determine if this object is modified by a deformation from the base mesh data");
1290 parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene in which to check the object");
1292 parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
1294 parm = RNA_def_boolean(func, "result", false, "", "Whether the object is deform-modified");
1295 RNA_def_function_return(func, parm);
1296
1297# ifndef NDEBUG
1298 /* mesh */
1299 func = RNA_def_function(srna, "dm_info", "rna_Object_me_eval_info");
1301 func,
1302 "Returns a string for original/evaluated mesh data (debug builds only, "
1303 "using context's or provided depsgraph to get evaluated mesh if needed)");
1305
1306 parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");
1308 parm = RNA_def_pointer(
1309 func,
1310 "depsgraph",
1311 "Depsgraph",
1312 "",
1313 "Depsgraph to use to get evaluated data, when called from original object "
1314 "(only needed if current Context's depsgraph is not suitable)");
1316 /* weak!, no way to return dynamic string type */
1317 parm = RNA_def_string(
1318 func, "result", nullptr, MESH_DM_INFO_STR_MAX, "", "Requested information");
1320 parm, PROP_THICK_WRAP, ParameterFlag(0)); /* needed for string return value */
1321 RNA_def_function_output(func, parm);
1322# endif /* !NDEBUG */
1323
1324 func = RNA_def_function(srna, "update_from_editmode", "rna_Object_update_from_editmode");
1325 RNA_def_function_ui_description(func, "Load the objects edit-mode data into the object data");
1327 parm = RNA_def_boolean(func, "result", false, "", "Success");
1328 RNA_def_function_return(func, parm);
1329
1330 func = RNA_def_function(srna, "cache_release", "BKE_object_free_caches");
1332 "Release memory used by caches associated with this object. "
1333 "Intended to be used by render engines only.");
1334}
1335
1336#endif /* RNA_RUNTIME */
void free_bvhtree_from_mesh(BVHTreeFromMesh *data)
Definition bvhutils.cc:1160
BVHTree * BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, const Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
Definition bvhutils.cc:899
@ BVHTREE_FROM_CORNER_TRIS
void BKE_camera_params_init(CameraParams *params)
bool BKE_camera_view_frame_fit_to_coords(const struct Depsgraph *depsgraph, const float(*cos)[3], int num_cos, struct Object *camera_ob, float r_co[3], float *r_scale)
void BKE_camera_params_from_object(CameraParams *params, const struct Object *cam_ob)
void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int winy, float aspx, float aspy)
void BKE_camera_params_compute_matrix(CameraParams *params)
void BKE_constraint_mat_convertspace(struct Object *ob, struct bPoseChannel *pchan, struct bConstraintOb *cob, float mat[4][4], short from, short to, bool keep_scale)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_crazyspace_api_eval(Depsgraph *depsgraph, Scene *scene, Object *object, ReportList *reports)
void BKE_crazyspace_api_displacement_to_original(Object *object, ReportList *reports, int vertex_index, const float displacement_deformed[3], float r_displacement[3])
void BKE_crazyspace_api_eval_clear(Object *object)
void BKE_crazyspace_api_displacement_to_deformed(Object *object, ReportList *reports, int vertex_index, const float displacement[3], float r_displacement_deformed[3])
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
#define G_MAIN
Key * BKE_key_from_object(Object *ob)
Definition key.cc:1820
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
bool BKE_object_is_visible_in_viewport(const View3D *v3d, const Object *ob)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
char * BKE_mesh_debug_info(const Mesh *mesh) ATTR_NONNULL(1) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
Definition mesh_debug.cc:31
General operations, lookup, etc. for blender objects.
void BKE_object_to_mesh_clear(Object *object)
void BKE_object_to_curve_clear(Object *object)
KeyBlock * BKE_object_shapekey_insert(Main *bmain, Object *ob, const char *name, bool from_mix)
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
bool BKE_object_shapekey_free(Main *bmain, Object *ob)
int BKE_object_is_deform_modified(Scene *scene, Object *ob)
bool BKE_object_shapekey_remove(Main *bmain, Object *ob, KeyBlock *kb)
const Mesh * BKE_object_get_mesh_deform_eval(const Object *object)
Mesh * BKE_object_to_mesh(Depsgraph *depsgraph, Object *object, bool preserve_all_data_layers)
Curve * BKE_object_to_curve(Object *object, Depsgraph *depsgraph, bool apply_modifiers)
int BKE_object_is_modified(Scene *scene, Object *ob)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BVH_RAYCAST_DIST_MAX
Definition BLI_kdopbvh.h:92
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
bool isect_ray_aabb_v3_simple(const float orig[3], const float dir[3], const float bb_min[3], const float bb_max[3], float *tmin, float *tmax)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1068
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1071
@ CONSTRAINT_SPACE_CUSTOM
@ CONSTRAINT_SPACE_POSE
@ CONSTRAINT_SPACE_WORLD
@ CONSTRAINT_SPACE_OWNLOCAL
@ CONSTRAINT_SPACE_LOCAL
@ CONSTRAINT_SPACE_PARLOCAL
@ BASE_HIDDEN
@ BASE_INDIRECT_ONLY
@ BASE_HOLDOUT
@ eModifierMode_Render
@ eModifierMode_Realtime
Object is a sort of wrapper for general info.
@ OB_HOLDOUT
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_CURVES_LEGACY
#define BASE_SELECTED(v3d, base)
#define BASE_VISIBLE(v3d, base)
#define WEIGHT_REPLACE
#define WEIGHT_ADD
#define WEIGHT_SUBTRACT
void ED_outliner_select_sync_from_object_tag(bContext *C)
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:708
wmWindow * ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm)
ScrArea * ED_screen_area_find_with_spacedata(const bScreen *screen, const SpaceLink *sl, bool only_visible)
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ PARM_OUTPUT
Definition RNA_types.hh:398
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_INT
Definition RNA_types.hh:66
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_XYZ
Definition RNA_types.hh:172
@ PROP_NONE
Definition RNA_types.hh:136
constexpr PointerRNA PointerRNA_NULL
Definition RNA_types.hh:45
#define ND_DRAW
Definition WM_types.hh:428
#define ND_OB_SELECT
Definition WM_types.hh:409
#define NC_SCENE
Definition WM_types.hh:345
#define NC_OBJECT
Definition WM_types.hh:346
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
const Depsgraph * depsgraph
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
ccl_device_inline float3 cos(float3 v)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
static ulong state[N]
void base_select(Base *base, eObjectSelect_Mode mode)
bool editmode_load(Main *bmain, Object *obedit)
float distance(float a, float b)
return ret
bool RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **r_identifier)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
#define MESH_DM_INFO_STR_MAX
static const EnumPropertyItem space_items[]
void RNA_api_object(StructRNA *srna)
#define FLT_MAX
Definition stdcycles.h:14
BVHTree_RayCastCallback raycast_callback
BVHTree_NearestPointCallback nearest_callback
short flag
unsigned short local_view_bits
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
ListBase block
CustomData face_data
ObjectRuntimeHandle * runtime
short visibility_flag
unsigned short base_local_view_bits
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
struct View3D * localvd
unsigned short local_view_uid
char name[64]
struct Scene * scene
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Scene * WM_window_get_active_scene(const wmWindow *win)