Blender  V3.3
rna_object_api.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 Blender Foundation. All rights reserved. */
3 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <time.h>
12 
13 #include "BLI_kdopbvh.h"
14 #include "BLI_utildefines.h"
15 
16 #include "RNA_define.h"
17 
18 #include "DNA_constraint_types.h"
19 #include "DNA_layer_types.h"
20 #include "DNA_modifier_types.h"
21 #include "DNA_object_types.h"
22 
23 #include "BKE_gpencil_curve.h"
24 #include "BKE_layer.h"
25 
26 #include "DEG_depsgraph.h"
27 
28 #include "ED_outliner.h"
29 
30 #include "rna_internal.h" /* own include */
31 
32 static const EnumPropertyItem space_items[] = {
33  {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space", "The most global space in Blender"},
35  "POSE",
36  0,
37  "Pose Space",
38  "The pose space of a bone (its armature's object space)"},
40  "LOCAL_WITH_PARENT",
41  0,
42  "Local With Parent",
43  "The rest pose local space of a bone (thus matrix includes parent transforms)"},
44  {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space", "The local space of an object/bone"},
45  {0, NULL, 0, NULL, NULL},
46 };
47 
48 #ifdef RNA_RUNTIME
49 
50 # include "BLI_math.h"
51 
52 # include "BKE_bvhutils.h"
53 # include "BKE_constraint.h"
54 # include "BKE_context.h"
55 # include "BKE_crazyspace.h"
56 # include "BKE_customdata.h"
57 # include "BKE_global.h"
58 # include "BKE_layer.h"
59 # include "BKE_main.h"
60 # include "BKE_mball.h"
61 # include "BKE_mesh.h"
62 # include "BKE_modifier.h"
63 # include "BKE_object.h"
64 # include "BKE_report.h"
65 # include "BKE_vfont.h"
66 
67 # include "ED_object.h"
68 # include "ED_screen.h"
69 
70 # include "DNA_curve_types.h"
71 # include "DNA_mesh_types.h"
72 # include "DNA_meshdata_types.h"
73 # include "DNA_scene_types.h"
74 # include "DNA_view3d_types.h"
75 
76 # include "DEG_depsgraph_query.h"
77 
78 # include "MEM_guardedalloc.h"
79 
80 static void rna_Object_select_set(
81  Object *ob, bContext *C, ReportList *reports, bool select, ViewLayer *view_layer)
82 {
83  if (view_layer == NULL) {
84  view_layer = CTX_data_view_layer(C);
85  }
86  Base *base = BKE_view_layer_base_find(view_layer, ob);
87 
88  if (!base) {
89  if (select) {
90  BKE_reportf(reports,
91  RPT_ERROR,
92  "Object '%s' can't be selected because it is not in View Layer '%s'!",
93  ob->id.name + 2,
94  view_layer->name);
95  }
96  return;
97  }
98 
100 
105 }
106 
107 static bool rna_Object_select_get(Object *ob, bContext *C, ViewLayer *view_layer)
108 {
109  if (view_layer == NULL) {
110  view_layer = CTX_data_view_layer(C);
111  }
112  Base *base = BKE_view_layer_base_find(view_layer, ob);
113 
114  if (!base) {
115  return false;
116  }
117 
118  return ((base->flag & BASE_SELECTED) != 0);
119 }
120 
121 static void rna_Object_hide_set(
122  Object *ob, bContext *C, ReportList *reports, bool hide, ViewLayer *view_layer)
123 {
124  if (view_layer == NULL) {
125  view_layer = CTX_data_view_layer(C);
126  }
127  Base *base = BKE_view_layer_base_find(view_layer, ob);
128 
129  if (!base) {
130  if (hide) {
131  BKE_reportf(reports,
132  RPT_ERROR,
133  "Object '%s' can't be hidden because it is not in View Layer '%s'!",
134  ob->id.name + 2,
135  view_layer->name);
136  }
137  return;
138  }
139 
140  if (hide) {
141  base->flag |= BASE_HIDDEN;
142  }
143  else {
144  base->flag &= ~BASE_HIDDEN;
145  }
146 
148  BKE_layer_collection_sync(scene, view_layer);
151 }
152 
153 static bool rna_Object_hide_get(Object *ob, bContext *C, ViewLayer *view_layer)
154 {
155  if (view_layer == NULL) {
156  view_layer = CTX_data_view_layer(C);
157  }
158  Base *base = BKE_view_layer_base_find(view_layer, ob);
159 
160  if (!base) {
161  return false;
162  }
163 
164  return ((base->flag & BASE_HIDDEN) != 0);
165 }
166 
167 static bool rna_Object_visible_get(Object *ob, bContext *C, ViewLayer *view_layer, View3D *v3d)
168 {
169  if (view_layer == NULL) {
170  view_layer = CTX_data_view_layer(C);
171  }
172  if (v3d == NULL) {
173  v3d = CTX_wm_view3d(C);
174  }
175  Base *base = BKE_view_layer_base_find(view_layer, ob);
176 
177  if (!base) {
178  return false;
179  }
180 
181  return BASE_VISIBLE(v3d, base);
182 }
183 
184 static bool rna_Object_holdout_get(Object *ob, bContext *C, ViewLayer *view_layer)
185 {
186  if (view_layer == NULL) {
187  view_layer = CTX_data_view_layer(C);
188  }
189  Base *base = BKE_view_layer_base_find(view_layer, ob);
190 
191  if (!base) {
192  return false;
193  }
194 
195  return ((base->flag & BASE_HOLDOUT) != 0) || ((ob->visibility_flag & OB_HOLDOUT) != 0);
196 }
197 
198 static bool rna_Object_indirect_only_get(Object *ob, bContext *C, ViewLayer *view_layer)
199 {
200  if (view_layer == NULL) {
201  view_layer = CTX_data_view_layer(C);
202  }
203  Base *base = BKE_view_layer_base_find(view_layer, ob);
204 
205  if (!base) {
206  return false;
207  }
208 
209  return ((base->flag & BASE_INDIRECT_ONLY) != 0);
210 }
211 
212 static Base *rna_Object_local_view_property_helper(bScreen *screen,
213  View3D *v3d,
214  ViewLayer *view_layer,
215  Object *ob,
216  ReportList *reports,
217  Scene **r_scene)
218 {
219  wmWindow *win = NULL;
220  if (v3d->localvd == NULL) {
221  BKE_report(reports, RPT_ERROR, "Viewport not in local view");
222  return NULL;
223  }
224 
225  if (view_layer == NULL) {
226  win = ED_screen_window_find(screen, G_MAIN->wm.first);
227  view_layer = WM_window_get_active_view_layer(win);
228  }
229 
230  Base *base = BKE_view_layer_base_find(view_layer, ob);
231  if (base == NULL) {
232  BKE_reportf(
233  reports, RPT_WARNING, "Object %s not in view layer %s", ob->id.name + 2, view_layer->name);
234  }
235  if (r_scene != NULL && win != NULL) {
236  *r_scene = win->scene;
237  }
238  return base;
239 }
240 
241 static bool rna_Object_local_view_get(Object *ob, ReportList *reports, View3D *v3d)
242 {
243  if (v3d->localvd == NULL) {
244  BKE_report(reports, RPT_ERROR, "Viewport not in local view");
245  return false;
246  }
247 
248  return ((ob->base_local_view_bits & v3d->local_view_uuid) != 0);
249 }
250 
251 static void rna_Object_local_view_set(Object *ob,
252  ReportList *reports,
253  PointerRNA *v3d_ptr,
254  bool state)
255 {
256  bScreen *screen = (bScreen *)v3d_ptr->owner_id;
257  View3D *v3d = v3d_ptr->data;
258  Scene *scene;
259  Base *base = rna_Object_local_view_property_helper(screen, v3d, NULL, ob, reports, &scene);
260  if (base == NULL) {
261  return; /* Error reported. */
262  }
263  const short local_view_bits_prev = base->local_view_bits;
265  if (local_view_bits_prev != base->local_view_bits) {
267  ScrArea *area = ED_screen_area_find_with_spacedata(screen, (SpaceLink *)v3d, true);
268  if (area) {
270  }
271  }
272 }
273 
274 static bool rna_Object_visible_in_viewport_get(Object *ob, View3D *v3d)
275 {
276  return BKE_object_is_visible_in_viewport(v3d, ob);
277 }
278 
279 /* Convert a given matrix from a space to another (using the object and/or a bone as
280  * reference). */
281 static void rna_Object_mat_convert_space(Object *ob,
282  ReportList *reports,
283  bPoseChannel *pchan,
284  float mat[16],
285  float mat_ret[16],
286  int from,
287  int to)
288 {
289  copy_m4_m4((float(*)[4])mat_ret, (float(*)[4])mat);
290 
293 
294  /* Error in case of invalid from/to values when pchan is NULL */
295  if (pchan == NULL) {
297  const char *identifier = NULL;
298  RNA_enum_identifier(space_items, from, &identifier);
299  BKE_reportf(reports,
300  RPT_ERROR,
301  "'from_space' '%s' is invalid when no pose bone is given!",
302  identifier);
303  return;
304  }
306  const char *identifier = NULL;
307  RNA_enum_identifier(space_items, to, &identifier);
308  BKE_reportf(reports,
309  RPT_ERROR,
310  "'to_space' '%s' is invalid when no pose bone is given!",
311  identifier);
312  return;
313  }
314  }
315  /* These checks are extra security, they should never occur. */
316  if (from == CONSTRAINT_SPACE_CUSTOM) {
317  const char *identifier = NULL;
318  RNA_enum_identifier(space_items, from, &identifier);
319  BKE_reportf(reports,
320  RPT_ERROR,
321  "'from_space' '%s' is invalid when no custom space is given!",
322  identifier);
323  return;
324  }
325  if (to == CONSTRAINT_SPACE_CUSTOM) {
326  const char *identifier = NULL;
327  RNA_enum_identifier(space_items, to, &identifier);
328  BKE_reportf(reports,
329  RPT_ERROR,
330  "'to_space' '%s' is invalid when no custom space is given!",
331  identifier);
332  return;
333  }
334 
335  BKE_constraint_mat_convertspace(ob, pchan, NULL, (float(*)[4])mat_ret, from, to, false);
336 }
337 
338 static void rna_Object_calc_matrix_camera(Object *ob,
340  float mat_ret[16],
341  int width,
342  int height,
343  float scalex,
344  float scaley)
345 {
346  const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
348 
349  /* setup parameters */
352 
353  /* Compute matrix, view-plane, etc. */
356 
357  copy_m4_m4((float(*)[4])mat_ret, params.winmat);
358 }
359 
360 static void rna_Object_camera_fit_coords(
361  Object *ob, Depsgraph *depsgraph, int num_cos, float *cos, float co_ret[3], float *scale_ret)
362 {
364  depsgraph, (const float(*)[3])cos, num_cos / 3, ob, co_ret, scale_ret);
365 }
366 
367 static void rna_Object_crazyspace_eval(Object *object,
368  ReportList *reports,
370  Scene *scene)
371 {
372  BKE_crazyspace_api_eval(depsgraph, scene, object, reports);
373 }
374 
375 static void rna_Object_crazyspace_displacement_to_deformed(Object *object,
376  ReportList *reports,
377  const int vertex_index,
378  float displacement[3],
379  float r_displacement_deformed[3])
380 {
382  object, reports, vertex_index, displacement, r_displacement_deformed);
383 }
384 
385 static void rna_Object_crazyspace_displacement_to_original(Object *object,
386  ReportList *reports,
387  const int vertex_index,
388  float displacement_deformed[3],
389  float r_displacement[3])
390 {
392  object, reports, vertex_index, displacement_deformed, r_displacement);
393 }
394 
395 static void rna_Object_crazyspace_eval_clear(Object *object)
396 {
398 }
399 
400 /* copied from Mesh_getFromObject and adapted to RNA interface */
401 static Mesh *rna_Object_to_mesh(Object *object,
402  ReportList *reports,
403  bool preserve_all_data_layers,
405 {
406  /* TODO(sergey): Make it more re-usable function, de-duplicate with
407  * rna_Main_meshes_new_from_object. */
408  switch (object->type) {
409  case OB_FONT:
410  case OB_CURVES_LEGACY:
411  case OB_SURF:
412  case OB_MBALL:
413  case OB_MESH:
414  break;
415  default:
416  BKE_report(reports, RPT_ERROR, "Object does not have geometry data");
417  return NULL;
418  }
419 
420  return BKE_object_to_mesh(depsgraph, object, preserve_all_data_layers);
421 }
422 
423 static void rna_Object_to_mesh_clear(Object *object)
424 {
425  BKE_object_to_mesh_clear(object);
426 }
427 
428 static Curve *rna_Object_to_curve(Object *object,
429  ReportList *reports,
431  bool apply_modifiers)
432 {
433  if (!ELEM(object->type, OB_FONT, OB_CURVES_LEGACY)) {
434  BKE_report(reports, RPT_ERROR, "Object is not a curve or a text");
435  return NULL;
436  }
437 
438  if (depsgraph == NULL) {
439  BKE_report(reports, RPT_ERROR, "Invalid depsgraph");
440  return NULL;
441  }
442 
443  return BKE_object_to_curve(object, depsgraph, apply_modifiers);
444 }
445 
446 static void rna_Object_to_curve_clear(Object *object)
447 {
449 }
450 
451 static PointerRNA rna_Object_shape_key_add(
452  Object *ob, bContext *C, ReportList *reports, const char *name, bool from_mix)
453 {
454  Main *bmain = CTX_data_main(C);
455  KeyBlock *kb = NULL;
456 
457  if ((kb = BKE_object_shapekey_insert(bmain, ob, name, from_mix))) {
458  PointerRNA keyptr;
459 
460  RNA_pointer_create((ID *)BKE_key_from_object(ob), &RNA_ShapeKey, kb, &keyptr);
462 
465 
466  return keyptr;
467  }
468  else {
469  BKE_reportf(reports, RPT_ERROR, "Object '%s' does not support shapes", ob->id.name + 2);
470  return PointerRNA_NULL;
471  }
472 }
473 
474 static void rna_Object_shape_key_remove(Object *ob,
475  Main *bmain,
476  ReportList *reports,
477  PointerRNA *kb_ptr)
478 {
479  KeyBlock *kb = kb_ptr->data;
480  Key *key = BKE_key_from_object(ob);
481 
482  if ((key == NULL) || BLI_findindex(&key->block, kb) == -1) {
483  BKE_report(reports, RPT_ERROR, "ShapeKey not found");
484  return;
485  }
486 
487  if (!BKE_object_shapekey_remove(bmain, ob, kb)) {
488  BKE_report(reports, RPT_ERROR, "Could not remove ShapeKey");
489  return;
490  }
491 
494 
495  RNA_POINTER_INVALIDATE(kb_ptr);
496 }
497 
498 static void rna_Object_shape_key_clear(Object *ob, Main *bmain)
499 {
500  BKE_object_shapekey_free(bmain, ob);
501 
504 }
505 
506 # if 0
507 static void rna_Mesh_assign_verts_to_group(
508  Object *ob, bDeformGroup *group, int *indices, int totindex, float weight, int assignmode)
509 {
510  if (ob->type != OB_MESH) {
511  BKE_report(reports, RPT_ERROR, "Object should be of mesh type");
512  return;
513  }
514 
515  Mesh *me = (Mesh *)ob->data;
516  int group_index = BLI_findlink(&ob->defbase, group);
517  if (group_index == -1) {
518  BKE_report(reports, RPT_ERROR, "No vertex groups assigned to mesh");
519  return;
520  }
521 
522  if (assignmode != WEIGHT_REPLACE && assignmode != WEIGHT_ADD && assignmode != WEIGHT_SUBTRACT) {
523  BKE_report(reports, RPT_ERROR, "Bad assignment mode");
524  return;
525  }
526 
527  /* makes a set of dVerts corresponding to the mVerts */
528  if (!me->dvert) {
529  create_dverts(&me->id);
530  }
531 
532  /* Loop list adding verts to group. */
533  for (i = 0; i < totindex; i++) {
534  if (i < 0 || i >= me->totvert) {
535  BKE_report(reports, RPT_ERROR, "Bad vertex index in list");
536  return;
537  }
538 
539  add_vert_defnr(ob, group_index, i, weight, assignmode);
540  }
541 }
542 # endif
543 
544 /* don't call inside a loop */
545 static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt)
546 {
547  const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
548  return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly;
549 }
550 
551 /* TODO(sergey): Make the Python API more clear that evaluation might happen, or require
552  * passing fully evaluated depsgraph. */
553 static Object *eval_object_ensure(Object *ob,
554  bContext *C,
555  ReportList *reports,
556  PointerRNA *rnaptr_depsgraph)
557 {
558  if (ob->runtime.data_eval == NULL) {
559  Object *ob_orig = ob;
560  Depsgraph *depsgraph = rnaptr_depsgraph != NULL ? rnaptr_depsgraph->data : NULL;
561  if (depsgraph == NULL) {
563  }
564  if (depsgraph != NULL) {
566  }
567  if (ob == NULL || BKE_object_get_evaluated_mesh(ob) == NULL) {
568  BKE_reportf(
569  reports, RPT_ERROR, "Object '%s' has no evaluated mesh data", ob_orig->id.name + 2);
570  return NULL;
571  }
572  }
573  return ob;
574 }
575 
576 static void rna_Object_ray_cast(Object *ob,
577  bContext *C,
578  ReportList *reports,
579  float origin[3],
580  float direction[3],
581  float distance,
582  PointerRNA *rnaptr_depsgraph,
583  bool *r_success,
584  float r_location[3],
585  float r_normal[3],
586  int *r_index)
587 {
588  bool success = false;
589 
590  /* TODO(sergey): This isn't very reliable check. It is possible to have non-NULL pointer
591  * but which is out of date, and possibly dangling one. */
592  if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) {
593  return;
594  }
595 
596  /* Test BoundBox first (efficiency) */
597  const BoundBox *bb = BKE_object_boundbox_get(ob);
598  float distmin;
599 
600  /* Needed for valid distance check from #isect_ray_aabb_v3_simple() call. */
601  normalize_v3(direction);
602 
603  if (!bb ||
604  (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) &&
605  distmin <= distance)) {
606  BVHTreeFromMesh treeData = {NULL};
607 
608  /* No need to managing allocation or freeing of the BVH data.
609  * This is generated and freed as needed. */
610  Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
611  BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
612 
613  /* may fail if the mesh has no faces, in that case the ray-cast misses */
614  if (treeData.tree != NULL) {
615  BVHTreeRayHit hit;
616 
617  hit.index = -1;
618  hit.dist = distance;
619 
620  if (BLI_bvhtree_ray_cast(treeData.tree,
621  origin,
622  direction,
623  0.0f,
624  &hit,
625  treeData.raycast_callback,
626  &treeData) != -1) {
627  if (hit.dist <= distance) {
628  *r_success = success = true;
629 
630  copy_v3_v3(r_location, hit.co);
631  copy_v3_v3(r_normal, hit.no);
632  *r_index = mesh_looptri_to_poly_index(mesh_eval, &treeData.looptri[hit.index]);
633  }
634  }
635 
636  free_bvhtree_from_mesh(&treeData);
637  }
638  }
639  if (success == false) {
640  *r_success = false;
641 
642  zero_v3(r_location);
643  zero_v3(r_normal);
644  *r_index = -1;
645  }
646 }
647 
648 static void rna_Object_closest_point_on_mesh(Object *ob,
649  bContext *C,
650  ReportList *reports,
651  float origin[3],
652  float distance,
653  PointerRNA *rnaptr_depsgraph,
654  bool *r_success,
655  float r_location[3],
656  float r_normal[3],
657  int *r_index)
658 {
659  BVHTreeFromMesh treeData = {NULL};
660 
661  if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) {
662  return;
663  }
664 
665  /* No need to managing allocation or freeing of the BVH data.
666  * this is generated and freed as needed. */
667  Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
668  BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_LOOPTRI, 4);
669 
670  if (treeData.tree == NULL) {
671  BKE_reportf(reports,
672  RPT_ERROR,
673  "Object '%s' could not create internal data for finding nearest point",
674  ob->id.name + 2);
675  return;
676  }
677  else {
678  BVHTreeNearest nearest;
679 
680  nearest.index = -1;
681  nearest.dist_sq = distance * distance;
682 
684  treeData.tree, origin, &nearest, treeData.nearest_callback, &treeData) != -1) {
685  *r_success = true;
686 
687  copy_v3_v3(r_location, nearest.co);
688  copy_v3_v3(r_normal, nearest.no);
689  *r_index = mesh_looptri_to_poly_index(mesh_eval, &treeData.looptri[nearest.index]);
690 
691  goto finally;
692  }
693  }
694 
695  *r_success = false;
696 
697  zero_v3(r_location);
698  zero_v3(r_normal);
699  *r_index = -1;
700 
701 finally:
702  free_bvhtree_from_mesh(&treeData);
703 }
704 
705 static bool rna_Object_is_modified(Object *ob, Scene *scene, int settings)
706 {
707  return BKE_object_is_modified(scene, ob) & settings;
708 }
709 
710 static bool rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings)
711 {
712  return BKE_object_is_deform_modified(scene, ob) & settings;
713 }
714 
715 # ifndef NDEBUG
716 
717 # include "BKE_mesh_runtime.h"
718 
719 void rna_Object_me_eval_info(
720  struct Object *ob, bContext *C, int type, PointerRNA *rnaptr_depsgraph, char *result)
721 {
722  Mesh *me_eval = NULL;
723  char *ret = NULL;
724 
725  result[0] = '\0';
726 
727  switch (type) {
728  case 1:
729  case 2:
730  if ((ob = eval_object_ensure(ob, C, NULL, rnaptr_depsgraph)) == NULL) {
731  return;
732  }
733  }
734 
735  switch (type) {
736  case 0:
737  if (ob->type == OB_MESH) {
738  me_eval = ob->data;
739  }
740  break;
741  case 1:
742  me_eval = ob->runtime.mesh_deform_eval;
743  break;
744  case 2:
745  me_eval = BKE_object_get_evaluated_mesh(ob);
746  break;
747  }
748 
749  if (me_eval) {
750  ret = BKE_mesh_debug_info(me_eval);
751  if (ret) {
752  strcpy(result, ret);
753  MEM_freeN(ret);
754  }
755  }
756 }
757 # else
758 void rna_Object_me_eval_info(struct Object *UNUSED(ob),
759  bContext *UNUSED(C),
760  int UNUSED(type),
761  PointerRNA *UNUSED(rnaptr_depsgraph),
762  char *result)
763 {
764  result[0] = '\0';
765 }
766 # endif /* NDEBUG */
767 
768 static bool rna_Object_update_from_editmode(Object *ob, Main *bmain)
769 {
770  /* fail gracefully if we aren't in edit-mode. */
771  const bool result = ED_object_editmode_load(bmain, ob);
772  if (result) {
773  /* Loading edit mesh to mesh changes geometry, and scripts might expect it to be properly
774  * informed about changes. */
776  }
777  return result;
778 }
779 
780 bool rna_Object_generate_gpencil_strokes(Object *ob,
781  bContext *C,
782  ReportList *reports,
783  Object *ob_gpencil,
784  bool use_collections,
785  float scale_thickness,
786  float sample)
787 {
788  if (ob->type != OB_CURVES_LEGACY) {
789  BKE_reportf(reports,
790  RPT_ERROR,
791  "Object '%s' is not valid for this operation! Only curves are supported",
792  ob->id.name + 2);
793  return false;
794  }
795  Main *bmain = CTX_data_main(C);
797 
799  bmain, scene, ob_gpencil, ob, use_collections, scale_thickness, sample);
800 
802 
803  return true;
804 }
805 #else /* RNA_RUNTIME */
806 
808 {
809  FunctionRNA *func;
810  PropertyRNA *parm;
811 
812  static const EnumPropertyItem mesh_type_items[] = {
813  {eModifierMode_Realtime, "PREVIEW", 0, "Preview", "Apply modifier preview settings"},
814  {eModifierMode_Render, "RENDER", 0, "Render", "Apply modifier render settings"},
815  {0, NULL, 0, NULL, NULL},
816  };
817 
818 # ifndef NDEBUG
819  static const EnumPropertyItem mesh_dm_info_items[] = {
820  {0, "SOURCE", 0, "Source", "Source mesh"},
821  {1, "DEFORM", 0, "Deform", "Objects deform mesh"},
822  {2, "FINAL", 0, "Final", "Objects final mesh"},
823  {0, NULL, 0, NULL, NULL},
824  };
825 # endif
826 
827  /* Special wrapper to access the base selection value */
828  func = RNA_def_function(srna, "select_get", "rna_Object_select_get");
830  func, "Test if the object is selected. The selection state is per view layer");
832  parm = RNA_def_pointer(
833  func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
834  parm = RNA_def_boolean(func, "result", 0, "", "Object selected");
835  RNA_def_function_return(func, parm);
836 
837  func = RNA_def_function(srna, "select_set", "rna_Object_select_set");
839  func, "Select or deselect the object. The selection state is per view layer");
841  parm = RNA_def_boolean(func, "state", 0, "", "Selection state to define");
843  parm = RNA_def_pointer(
844  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");
853  parm = RNA_def_boolean(func, "result", 0, "", "Object hidden");
854  RNA_def_function_return(func, parm);
855 
856  func = RNA_def_function(srna, "hide_set", "rna_Object_hide_set");
858  func, "Hide the object for viewport editing. This hiding state is per view layer");
860  parm = RNA_def_boolean(func, "state", 0, "", "Hide state to define");
862  parm = RNA_def_pointer(
863  func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
864 
865  func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get");
867  "Test if the object is visible in the 3D viewport, taking into "
868  "account all visibility settings");
870  parm = RNA_def_pointer(
871  func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
872  parm = RNA_def_pointer(
873  func, "viewport", "SpaceView3D", "", "Use this instead of the active 3D viewport");
874  parm = RNA_def_boolean(func, "result", 0, "", "Object visible");
875  RNA_def_function_return(func, parm);
876 
877  func = RNA_def_function(srna, "holdout_get", "rna_Object_holdout_get");
878  RNA_def_function_ui_description(func, "Test if object is masked in the view layer");
880  parm = RNA_def_pointer(
881  func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
882  parm = RNA_def_boolean(func, "result", 0, "", "Object holdout");
883  RNA_def_function_return(func, parm);
884 
885  func = RNA_def_function(srna, "indirect_only_get", "rna_Object_indirect_only_get");
887  "Test if object is set to contribute only indirectly (through "
888  "shadows and reflections) in the view layer");
890  parm = RNA_def_pointer(
891  func, "view_layer", "ViewLayer", "", "Use this instead of the active view layer");
892  parm = RNA_def_boolean(func, "result", 0, "", "Object indirect only");
893  RNA_def_function_return(func, parm);
894 
895  /* Local View */
896  func = RNA_def_function(srna, "local_view_get", "rna_Object_local_view_get");
897  RNA_def_function_ui_description(func, "Get the local view state for this object");
899  parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
901  parm = RNA_def_boolean(func, "result", 0, "", "Object local view state");
902  RNA_def_function_return(func, parm);
903 
904  func = RNA_def_function(srna, "local_view_set", "rna_Object_local_view_set");
905  RNA_def_function_ui_description(func, "Set the local view state for this object");
907  parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view");
909  parm = RNA_def_boolean(func, "state", 0, "", "Local view state to define");
911 
912  /* Viewport */
913  func = RNA_def_function(srna, "visible_in_viewport_get", "rna_Object_visible_in_viewport_get");
915  func, "Check for local view and local collections for this viewport and object");
916  parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local collections");
918  parm = RNA_def_boolean(func, "result", 0, "", "Object viewport visibility");
919  RNA_def_function_return(func, parm);
920 
921  /* Matrix space conversion */
922  func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space");
924  func, "Convert (transform) the given matrix from one space to another");
926  parm = RNA_def_pointer(
927  func,
928  "pose_bone",
929  "PoseBone",
930  "",
931  "Bone to use to define spaces (may be None, in which case only the two 'WORLD' and "
932  "'LOCAL' spaces are usable)");
933  parm = RNA_def_property(func, "matrix", PROP_FLOAT, PROP_MATRIX);
935  RNA_def_property_ui_text(parm, "", "The matrix to transform");
936  parm = RNA_def_property(func, "matrix_return", PROP_FLOAT, PROP_MATRIX);
938  RNA_def_property_ui_text(parm, "", "The transformed matrix");
939  RNA_def_function_output(func, parm);
940  parm = RNA_def_enum(func,
941  "from_space",
942  space_items,
944  "",
945  "The space in which 'matrix' is currently");
946  parm = RNA_def_enum(func,
947  "to_space",
948  space_items,
950  "",
951  "The space to which you want to transform 'matrix'");
952 
953  /* Camera-related operations */
954  func = RNA_def_function(srna, "calc_matrix_camera", "rna_Object_calc_matrix_camera");
956  "Generate the camera projection matrix of this object "
957  "(mostly useful for Camera and Light types)");
958  parm = RNA_def_pointer(
959  func, "depsgraph", "Depsgraph", "", "Depsgraph to get evaluated data from");
961  parm = RNA_def_property(func, "result", PROP_FLOAT, PROP_MATRIX);
963  RNA_def_property_ui_text(parm, "", "The camera projection matrix");
964  RNA_def_function_output(func, parm);
965  parm = RNA_def_int(func, "x", 1, 0, INT_MAX, "", "Width of the render area", 0, 10000);
966  parm = RNA_def_int(func, "y", 1, 0, INT_MAX, "", "Height of the render area", 0, 10000);
967  parm = RNA_def_float(
968  func, "scale_x", 1.0f, 1.0e-6f, FLT_MAX, "", "Width scaling factor", 1.0e-2f, 100.0f);
969  parm = RNA_def_float(
970  func, "scale_y", 1.0f, 1.0e-6f, FLT_MAX, "", "Height scaling factor", 1.0e-2f, 100.0f);
971 
972  func = RNA_def_function(srna, "camera_fit_coords", "rna_Object_camera_fit_coords");
974  "Compute the coordinate (and scale for ortho cameras) "
975  "given object should be to 'see' all given coordinates");
976  parm = RNA_def_pointer(
977  func, "depsgraph", "Depsgraph", "", "Depsgraph to get evaluated data from");
979  parm = RNA_def_float_array(func,
980  "coordinates",
981  1,
982  NULL,
983  -FLT_MAX,
984  FLT_MAX,
985  "",
986  "Coordinates to fit in",
987  -FLT_MAX,
988  FLT_MAX);
990  parm = RNA_def_property(func, "co_return", PROP_FLOAT, PROP_XYZ);
991  RNA_def_property_array(parm, 3);
992  RNA_def_property_ui_text(parm, "", "The location to aim to be able to see all given points");
994  parm = RNA_def_property(func, "scale_return", PROP_FLOAT, PROP_NONE);
996  parm, "", "The ortho scale to aim to be able to see all given points (if relevant)");
998 
999  /* Crazy-space access. */
1000 
1001  func = RNA_def_function(srna, "crazyspace_eval", "rna_Object_crazyspace_eval");
1003  func,
1004  "Compute orientation mapping between vertices of an original object and object with shape "
1005  "keys and deforming modifiers applied."
1006  "The evaluation is to be freed with the crazyspace_eval_free function");
1008  parm = RNA_def_pointer(
1009  func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph");
1011  parm = RNA_def_pointer(func, "scene", "Scene", "Scene", "Scene of the object");
1013 
1014  func = RNA_def_function(srna,
1015  "crazyspace_displacement_to_deformed",
1016  "rna_Object_crazyspace_displacement_to_deformed");
1018  func, "Convert displacement vector from non-deformed object space to deformed object space");
1020  RNA_def_property(func, "vertex_index", PROP_INT, PROP_NONE);
1022  parm = RNA_def_property(func, "displacement", PROP_FLOAT, PROP_XYZ);
1023  RNA_def_property_array(parm, 3);
1024  parm = RNA_def_property(func, "displacement_deformed", PROP_FLOAT, PROP_XYZ);
1025  RNA_def_property_array(parm, 3);
1026  RNA_def_function_output(func, parm);
1027 
1028  func = RNA_def_function(srna,
1029  "crazyspace_displacement_to_original",
1030  "rna_Object_crazyspace_displacement_to_original");
1032  func, "Convert displacement vector from deformed object space to non-deformed object space");
1034  RNA_def_property(func, "vertex_index", PROP_INT, PROP_NONE);
1036  parm = RNA_def_property(func, "displacement", PROP_FLOAT, PROP_XYZ);
1037  RNA_def_property_array(parm, 3);
1038  parm = RNA_def_property(func, "displacement_original", PROP_FLOAT, PROP_XYZ);
1039  RNA_def_property_array(parm, 3);
1040  RNA_def_function_output(func, parm);
1041 
1042  RNA_def_function(srna, "crazyspace_eval_clear", "rna_Object_crazyspace_eval_clear");
1043  RNA_def_function_ui_description(func, "Free evaluated state of crazyspace");
1044 
1045  /* mesh */
1046  func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
1048  func,
1049  "Create a Mesh data-block from the current state of the object. The object owns the "
1050  "data-block. To force free it use to_mesh_clear(). "
1051  "The result is temporary and can not be used by objects from the main database");
1053  RNA_def_boolean(func,
1054  "preserve_all_data_layers",
1055  false,
1056  "",
1057  "Preserve all data layers in the mesh, like UV maps and vertex groups. "
1058  "By default Blender only computes the subset of data layers needed for viewport "
1059  "display and rendering, for better performance");
1061  func,
1062  "depsgraph",
1063  "Depsgraph",
1064  "Dependency Graph",
1065  "Evaluated dependency graph which is required when preserve_all_data_layers is true");
1066  parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object");
1067  RNA_def_function_return(func, parm);
1068 
1069  func = RNA_def_function(srna, "to_mesh_clear", "rna_Object_to_mesh_clear");
1070  RNA_def_function_ui_description(func, "Clears mesh data-block created by to_mesh()");
1071 
1072  /* curve */
1073  func = RNA_def_function(srna, "to_curve", "rna_Object_to_curve");
1075  func,
1076  "Create a Curve data-block from the current state of the object. This only works for curve "
1077  "and text objects. The object owns the data-block. To force free it, use to_curve_clear(). "
1078  "The result is temporary and can not be used by objects from the main database");
1080  parm = RNA_def_pointer(
1081  func, "depsgraph", "Depsgraph", "Dependency Graph", "Evaluated dependency graph");
1083  RNA_def_boolean(func,
1084  "apply_modifiers",
1085  false,
1086  "",
1087  "Apply the deform modifiers on the control points of the curve. This is only "
1088  "supported for curve objects");
1089  parm = RNA_def_pointer(func, "curve", "Curve", "", "Curve created from object");
1090  RNA_def_function_return(func, parm);
1091 
1092  func = RNA_def_function(srna, "to_curve_clear", "rna_Object_to_curve_clear");
1093  RNA_def_function_ui_description(func, "Clears curve data-block created by to_curve()");
1094 
1095  /* Armature */
1096  func = RNA_def_function(srna, "find_armature", "BKE_modifiers_is_deformed_by_armature");
1098  func, "Find armature influencing this object as a parent or via a modifier");
1099  parm = RNA_def_pointer(
1100  func, "ob_arm", "Object", "", "Armature object influencing this object or NULL");
1101  RNA_def_function_return(func, parm);
1102 
1103  /* Shape key */
1104  func = RNA_def_function(srna, "shape_key_add", "rna_Object_shape_key_add");
1105  RNA_def_function_ui_description(func, "Add shape key to this object");
1107  RNA_def_string(func, "name", "Key", 0, "", "Unique name for the new keyblock"); /* optional */
1108  RNA_def_boolean(func, "from_mix", 1, "", "Create new shape from existing mix of shapes");
1109  parm = RNA_def_pointer(func, "key", "ShapeKey", "", "New shape keyblock");
1111  RNA_def_function_return(func, parm);
1112 
1113  func = RNA_def_function(srna, "shape_key_remove", "rna_Object_shape_key_remove");
1114  RNA_def_function_ui_description(func, "Remove a Shape Key from this object");
1116  parm = RNA_def_pointer(func, "key", "ShapeKey", "", "Keyblock to be removed");
1119 
1120  func = RNA_def_function(srna, "shape_key_clear", "rna_Object_shape_key_clear");
1121  RNA_def_function_ui_description(func, "Remove all Shape Keys from this object");
1123 
1124  /* Ray Cast */
1125  func = RNA_def_function(srna, "ray_cast", "rna_Object_ray_cast");
1127  func,
1128  "Cast a ray onto evaluated geometry, in object space "
1129  "(using context's or provided depsgraph to get evaluated mesh if needed)");
1131 
1132  /* ray start and end */
1133  parm = RNA_def_float_vector(func,
1134  "origin",
1135  3,
1136  NULL,
1137  -FLT_MAX,
1138  FLT_MAX,
1139  "",
1140  "Origin of the ray, in object space",
1141  -1e4,
1142  1e4);
1144  parm = RNA_def_float_vector(func,
1145  "direction",
1146  3,
1147  NULL,
1148  -FLT_MAX,
1149  FLT_MAX,
1150  "",
1151  "Direction of the ray, in object space",
1152  -1e4,
1153  1e4);
1155  RNA_def_float(func,
1156  "distance",
1158  0.0,
1160  "",
1161  "Maximum distance",
1162  0.0,
1164  parm = RNA_def_pointer(
1165  func,
1166  "depsgraph",
1167  "Depsgraph",
1168  "",
1169  "Depsgraph to use to get evaluated data, when called from original object "
1170  "(only needed if current Context's depsgraph is not suitable)");
1172 
1173  /* return location and normal */
1174  parm = RNA_def_boolean(func, "result", 0, "", "Whether the ray successfully hit the geometry");
1175  RNA_def_function_output(func, parm);
1176  parm = RNA_def_float_vector(func,
1177  "location",
1178  3,
1179  NULL,
1180  -FLT_MAX,
1181  FLT_MAX,
1182  "Location",
1183  "The hit location of this ray cast",
1184  -1e4,
1185  1e4);
1187  RNA_def_function_output(func, parm);
1188  parm = RNA_def_float_vector(func,
1189  "normal",
1190  3,
1191  NULL,
1192  -FLT_MAX,
1193  FLT_MAX,
1194  "Normal",
1195  "The face normal at the ray cast hit location",
1196  -1e4,
1197  1e4);
1199  RNA_def_function_output(func, parm);
1200  parm = RNA_def_int(
1201  func, "index", 0, 0, 0, "", "The face index, -1 when original data isn't available", 0, 0);
1202  RNA_def_function_output(func, parm);
1203 
1204  /* Nearest Point */
1205  func = RNA_def_function(srna, "closest_point_on_mesh", "rna_Object_closest_point_on_mesh");
1207  func,
1208  "Find the nearest point on evaluated geometry, in object space "
1209  "(using context's or provided depsgraph to get evaluated mesh if needed)");
1211 
1212  /* location of point for test and max distance */
1213  parm = RNA_def_float_vector(func,
1214  "origin",
1215  3,
1216  NULL,
1217  -FLT_MAX,
1218  FLT_MAX,
1219  "",
1220  "Point to find closest geometry from (in object space)",
1221  -1e4,
1222  1e4);
1224  /* default is sqrt(FLT_MAX) */
1225  RNA_def_float(
1226  func, "distance", 1.844674352395373e+19, 0.0, FLT_MAX, "", "Maximum distance", 0.0, FLT_MAX);
1227  parm = RNA_def_pointer(
1228  func,
1229  "depsgraph",
1230  "Depsgraph",
1231  "",
1232  "Depsgraph to use to get evaluated data, when called from original object "
1233  "(only needed if current Context's depsgraph is not suitable)");
1235 
1236  /* return location and normal */
1237  parm = RNA_def_boolean(func, "result", 0, "", "Whether closest point on geometry was found");
1238  RNA_def_function_output(func, parm);
1239  parm = RNA_def_float_vector(func,
1240  "location",
1241  3,
1242  NULL,
1243  -FLT_MAX,
1244  FLT_MAX,
1245  "Location",
1246  "The location on the object closest to the point",
1247  -1e4,
1248  1e4);
1250  RNA_def_function_output(func, parm);
1251  parm = RNA_def_float_vector(func,
1252  "normal",
1253  3,
1254  NULL,
1255  -FLT_MAX,
1256  FLT_MAX,
1257  "Normal",
1258  "The face normal at the closest point",
1259  -1e4,
1260  1e4);
1262  RNA_def_function_output(func, parm);
1263 
1264  parm = RNA_def_int(
1265  func, "index", 0, 0, 0, "", "The face index, -1 when original data isn't available", 0, 0);
1266  RNA_def_function_output(func, parm);
1267 
1268  /* View */
1269 
1270  /* utility function for checking if the object is modified */
1271  func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified");
1273  "Determine if this object is modified from the base mesh data");
1274  parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene in which to check the object");
1276  parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
1278  parm = RNA_def_boolean(func, "result", 0, "", "Whether the object is modified");
1279  RNA_def_function_return(func, parm);
1280 
1281  func = RNA_def_function(srna, "is_deform_modified", "rna_Object_is_deform_modified");
1283  func, "Determine if this object is modified by a deformation from the base mesh data");
1284  parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene in which to check the object");
1286  parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply");
1288  parm = RNA_def_boolean(func, "result", 0, "", "Whether the object is deform-modified");
1289  RNA_def_function_return(func, parm);
1290 
1291 # ifndef NDEBUG
1292  /* mesh */
1293  func = RNA_def_function(srna, "dm_info", "rna_Object_me_eval_info");
1295  func,
1296  "Returns a string for original/evaluated mesh data (debug builds only, "
1297  "using context's or provided depsgraph to get evaluated mesh if needed)");
1299 
1300  parm = RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply");
1302  parm = RNA_def_pointer(
1303  func,
1304  "depsgraph",
1305  "Depsgraph",
1306  "",
1307  "Depsgraph to use to get evaluated data, when called from original object "
1308  "(only needed if current Context's depsgraph is not suitable)");
1310  /* weak!, no way to return dynamic string type */
1311  parm = RNA_def_string(func, "result", NULL, 16384, "", "Requested information");
1312  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */
1313  RNA_def_function_output(func, parm);
1314 # endif /* NDEBUG */
1315 
1316  func = RNA_def_function(srna, "update_from_editmode", "rna_Object_update_from_editmode");
1317  RNA_def_function_ui_description(func, "Load the objects edit-mode data into the object data");
1319  parm = RNA_def_boolean(func, "result", 0, "", "Success");
1320  RNA_def_function_return(func, parm);
1321 
1322  func = RNA_def_function(srna, "cache_release", "BKE_object_free_caches");
1324  "Release memory used by caches associated with this object. "
1325  "Intended to be used by render engines only");
1326 
1327  /* Convert curve object to gpencil strokes. */
1328  func = RNA_def_function(srna, "generate_gpencil_strokes", "rna_Object_generate_gpencil_strokes");
1329  RNA_def_function_ui_description(func, "Convert a curve object to grease pencil strokes.");
1331 
1332  parm = RNA_def_pointer(func,
1333  "grease_pencil_object",
1334  "Object",
1335  "",
1336  "Grease Pencil object used to create new strokes");
1338  parm = RNA_def_boolean(func, "use_collections", true, "", "Use Collections");
1339  parm = RNA_def_float(
1340  func, "scale_thickness", 1.0f, 0.0f, FLT_MAX, "", "Thickness scaling factor", 0.0f, 100.0f);
1341  parm = RNA_def_float(
1342  func, "sample", 0.0f, 0.0f, FLT_MAX, "", "Sample distance, zero to disable", 0.0f, 100.0f);
1343  parm = RNA_def_boolean(func, "result", 0, "", "Result");
1344  RNA_def_function_return(func, parm);
1345 }
1346 
1347 #endif /* RNA_RUNTIME */
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
Definition: bvhutils.cc:1410
@ BVHTREE_FROM_LOOPTRI
Definition: BKE_bvhutils.h:73
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, const struct Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
Definition: bvhutils.cc:1213
void BKE_camera_params_init(CameraParams *params)
Definition: camera.c:265
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)
Definition: camera.c:364
void BKE_camera_params_compute_matrix(CameraParams *params)
Definition: camera.c:429
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)
Definition: constraint.c:245
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
void BKE_crazyspace_api_eval(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object, struct ReportList *reports)
Definition: crazyspace.cc:515
void BKE_crazyspace_api_displacement_to_original(struct Object *object, struct ReportList *reports, int vertex_index, float displacement_deformed[3], float r_displacement[3])
Definition: crazyspace.cc:561
void BKE_crazyspace_api_displacement_to_deformed(struct Object *object, struct ReportList *reports, int vertex_index, float displacement[3], float r_displacement_deformed[3])
Definition: crazyspace.cc:541
void BKE_crazyspace_api_eval_clear(struct Object *object)
Definition: crazyspace.cc:585
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_get_layer(const struct CustomData *data, int type)
#define G_MAIN
Definition: BKE_global.h:267
void BKE_gpencil_convert_curve(struct Main *bmain, struct Scene *scene, struct Object *ob_gp, struct Object *ob_cu, bool use_collections, float scale_thickness, float sample)
struct Key * BKE_key_from_object(struct Object *ob)
Definition: key.c:1803
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:379
bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Object *ob)
void BKE_layer_collection_sync(const struct Scene *scene, struct ViewLayer *view_layer)
char * BKE_mesh_debug_info(const struct Mesh *me) ATTR_NONNULL(1) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
General operations, lookup, etc. for blender objects.
void BKE_object_to_mesh_clear(struct Object *object)
Definition: object.cc:5529
int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob)
Definition: object.cc:4982
struct Mesh * BKE_object_get_evaluated_mesh(const struct Object *object)
struct Curve * BKE_object_to_curve(struct Object *object, struct Depsgraph *depsgraph, bool apply_modifiers)
Definition: object.cc:5538
struct KeyBlock * BKE_object_shapekey_insert(struct Main *bmain, struct Object *ob, const char *name, bool from_mix)
Definition: object.cc:4697
struct Mesh * BKE_object_to_mesh(struct Depsgraph *depsgraph, struct Object *object, bool preserve_all_data_layers)
Definition: object.cc:5520
const struct BoundBox * BKE_object_boundbox_get(struct Object *ob)
Definition: object.cc:3684
void BKE_object_to_curve_clear(struct Object *object)
Definition: object.cc:5547
int BKE_object_is_modified(struct Scene *scene, struct Object *ob)
Definition: object.cc:4854
bool BKE_object_shapekey_remove(struct Main *bmain, struct Object *ob, struct KeyBlock *kb)
Definition: object.cc:4746
bool BKE_object_shapekey_free(struct Main *bmain, struct Object *ob)
Definition: object.cc:4729
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.c:83
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BVH_RAYCAST_DIST_MAX
Definition: BLI_kdopbvh.h:89
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
Definition: BLI_kdopbvh.c:1942
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
Definition: BLI_kdopbvh.c:1616
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) 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)
Definition: math_geom.c:3124
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
MINLINE float normalize_v3(float r[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
@ ID_RECALC_SELECT
Definition: DNA_ID.h:818
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ID_RECALC_BASE_FLAGS
Definition: DNA_ID.h:821
@ CONSTRAINT_SPACE_CUSTOM
@ CONSTRAINT_SPACE_POSE
@ CONSTRAINT_SPACE_WORLD
@ CONSTRAINT_SPACE_OWNLOCAL
@ CONSTRAINT_SPACE_LOCAL
@ CONSTRAINT_SPACE_PARLOCAL
@ CD_ORIGINDEX
@ BASE_HIDDEN
@ BASE_INDIRECT_ONLY
@ BASE_HOLDOUT
@ BASE_SELECTED
@ 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_VISIBLE(v3d, base)
#define WEIGHT_REPLACE
Definition: ED_mesh.h:449
#define WEIGHT_ADD
Definition: ED_mesh.h:450
#define WEIGHT_SUBTRACT
Definition: ED_mesh.h:451
void ED_object_base_select(struct Base *base, eObjectSelect_Mode mode)
Definition: object_select.c:76
bool ED_object_editmode_load(struct Main *bmain, struct Object *obedit)
Definition: object_edit.c:648
@ BA_DESELECT
Definition: ED_object.h:154
@ BA_SELECT
Definition: ED_object.h:155
void ED_outliner_select_sync_from_object_tag(struct bContext *C)
void ED_area_tag_redraw(ScrArea *area)
Definition: area.c:729
struct wmWindow * ED_screen_window_find(const struct bScreen *screen, const struct wmWindowManager *wm)
ScrArea * ED_screen_area_find_with_spacedata(const bScreen *screen, const struct SpaceLink *sl, bool only_visible)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
#define RNA_POINTER_INVALIDATE(ptr)
Definition: RNA_access.h:744
@ PARM_RNAPTR
Definition: RNA_types.h:354
@ PARM_REQUIRED
Definition: RNA_types.h:352
@ PARM_OUTPUT
Definition: RNA_types.h:353
@ FUNC_USE_REPORTS
Definition: RNA_types.h:663
@ FUNC_USE_MAIN
Definition: RNA_types.h:661
@ FUNC_USE_CONTEXT
Definition: RNA_types.h:662
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_THICK_WRAP
Definition: RNA_types.h:285
@ PROP_DYNAMIC
Definition: RNA_types.h:290
@ PROP_NEVER_NULL
Definition: RNA_types.h:239
@ PROP_MATRIX
Definition: RNA_types.h:158
@ PROP_XYZ
Definition: RNA_types.h:162
@ PROP_NONE
Definition: RNA_types.h:126
#define C
Definition: RandGen.cpp:25
#define ND_DRAW
Definition: WM_types.h:410
#define ND_DATA
Definition: WM_types.h:456
#define ND_OB_SELECT
Definition: WM_types.h:390
#define NC_SCENE
Definition: WM_types.h:328
#define NC_GPENCIL
Definition: WM_types.h:349
#define NC_OBJECT
Definition: WM_types.h:329
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
StackEntry * from
Scene scene
const Depsgraph * depsgraph
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
const int state
ccl_gpu_kernel_postfix int ccl_global int * indices
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
Definition: rall1d.h:319
static void area(int d1, int d2, int e1, int e2, float weights[2])
T distance(const T &a, const T &b)
return ret
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:61
bool RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **r_identifier)
Definition: rna_access.c:1668
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4170
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1526
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4312
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:4076
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4273
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4337
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1598
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1539
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4347
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1595
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4342
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1518
static const EnumPropertyItem space_items[]
void RNA_api_object(StructRNA *srna)
BVHTree_RayCastCallback raycast_callback
Definition: BKE_bvhutils.h:54
struct BVHTree * tree
Definition: BKE_bvhutils.h:50
BVHTree_NearestPointCallback nearest_callback
Definition: BKE_bvhutils.h:53
const struct MLoopTri * looptri
Definition: BKE_bvhutils.h:62
float co[3]
Definition: BLI_kdopbvh.h:43
float no[3]
Definition: BLI_kdopbvh.h:46
float co[3]
Definition: BLI_kdopbvh.h:68
float no[3]
Definition: BLI_kdopbvh.h:70
short flag
unsigned short local_view_bits
float vec[8][3]
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
ListBase block
Definition: DNA_key_types.h:84
unsigned int poly
Definition: BKE_main.h:121
struct MDeformVert * dvert
int totvert
CustomData pdata
struct Mesh * mesh_deform_eval
struct ID * data_eval
Object_Runtime runtime
short visibility_flag
unsigned short base_local_view_bits
void * data
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
unsigned short local_view_uuid
struct View3D * localvd
char name[64]
struct Scene * scene
void WM_main_add_notifier(unsigned int 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)
Definition: wm_window.c:2217