2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup RNA
|
2011-02-27 20:20:01 +00:00
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstdlib>
|
2008-10-31 23:50:02 +00:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
#include "DNA_action_types.h"
|
2025-01-26 20:08:09 +01:00
|
|
|
#include "DNA_layer_types.h"
|
2020-01-17 19:14:23 +01:00
|
|
|
#include "DNA_lightprobe_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_meta_types.h"
|
2008-10-31 23:50:02 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
#include "BLI_math_rotation.h"
|
2012-03-24 01:24:58 +00:00
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2019-02-12 22:13:42 +01:00
|
|
|
|
2023-08-02 22:14:18 +02:00
|
|
|
#include "BKE_paint.hh"
|
2014-11-18 23:52:17 +01:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_define.hh"
|
|
|
|
|
#include "RNA_enum_types.hh"
|
2013-03-07 02:44:55 +00:00
|
|
|
|
2024-01-31 11:49:50 -05:00
|
|
|
#include "rna_internal.hh"
|
2013-03-07 02:44:55 +00:00
|
|
|
|
2024-03-26 21:51:09 -04:00
|
|
|
#include "ED_object_vgroup.hh"
|
2010-09-07 05:47:34 +00:00
|
|
|
|
2023-08-04 23:11:22 +02:00
|
|
|
#include "WM_api.hh"
|
|
|
|
|
#include "WM_types.hh"
|
2009-01-01 15:52:51 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_mode_items[] = {
|
Fix for [#35224] Transform Orientation - order inconsistency
Fix turned out to remove as much "manual UI" from 3D view header as possible. Mode selector and all transform manipulators/orientations stuff are now RNA-based UI (leaving basically only edit mesh select modes with custom handlers, as they have some quite specific features).
To achieve this, four main modifications were done:
* enum-operator-generated menus are now MENU (i.e. dropdown lists) in headers too.
* All bit-flag enums expanded in ROW buttons now have a handling consistent with e.g. layers, or what we already have for transform manipulators, i.e. clicking select only one element, shift-click to select multiple ones.
* Consequently, the three RNA booleans manipulators flags are merged into a single bit-flag enum (yes, this is also an API change, though I doubt many scripts use it).
* Now the width of enum-based dropdown lists is computed from longest item name in enum, no more from a dummy place holder string (when no label/name is given).
All this allows to remove some code from 3DView/transform areas, that was actually mostly duplicating RNA/operator one.
Also done a few optimizations here and there (among others, do not pass &numitems to RNA_property_enum_items() when you do not need it, saves at least an iteration over enum items to count them).
Many thanks to Brecht for the reviews!
2013-05-12 13:16:11 +00:00
|
|
|
{OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
|
|
|
|
|
{OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
|
Pie Menus C code backend.
This commit merges the code in the pie-menu branch.
As per decisions taken the last few days, there are no pie menus
included and there will be an official add-on including overrides of
some keys with pie menus. However, people will now be able to use the
new code in python.
Full Documentation is in http://wiki.blender.org/index.php/Dev:Ref/
Thanks:
Campbell Barton, Dalai Felinto and Ton Roosendaal for the code review
and design comments
Jonathan Williamson, Pawel Lyczkowski, Pablo Vazquez among others for
suggestions during the development.
Special Thanks to Sean Olson, for his support, suggestions, testing and
merciless bugging so that I would finish the pie menu code. Without him
we wouldn't be here. Also to the rest of the developers of the original
python add-on, Patrick Moore and Dan Eicher and finally to Matt Ebb, who
did the research and first implementation and whose code I used to get
started.
2014-08-11 10:39:59 +02:00
|
|
|
{OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
|
2018-06-09 12:55:10 +02:00
|
|
|
{OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
|
2018-05-30 13:47:24 +02:00
|
|
|
{OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
|
2018-06-09 12:55:10 +02:00
|
|
|
{OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
|
2009-08-16 05:48:07 +00:00
|
|
|
{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
|
2016-12-28 17:30:58 +01:00
|
|
|
{OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
|
2023-07-03 15:15:54 +02:00
|
|
|
{OB_MODE_EDIT_GPENCIL_LEGACY,
|
2018-12-14 16:45:57 +01:00
|
|
|
"EDIT_GPENCIL",
|
|
|
|
|
ICON_EDITMODE_HLT,
|
|
|
|
|
"Edit Mode",
|
|
|
|
|
"Edit Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_SCULPT_GREASE_PENCIL,
|
|
|
|
|
"SCULPT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_SCULPTMODE_HLT,
|
|
|
|
|
"Sculpt Mode",
|
|
|
|
|
"Sculpt Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_PAINT_GREASE_PENCIL,
|
|
|
|
|
"PAINT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_GREASEPENCIL,
|
2021-04-19 17:12:29 +02:00
|
|
|
"Draw Mode",
|
2018-12-14 16:45:57 +01:00
|
|
|
"Paint Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_WEIGHT_GREASE_PENCIL,
|
|
|
|
|
"WEIGHT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_WPAINT_HLT,
|
|
|
|
|
"Weight Paint",
|
|
|
|
|
"Grease Pencil Weight Paint Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_VERTEX_GREASE_PENCIL,
|
|
|
|
|
"VERTEX_GREASE_PENCIL",
|
2021-01-26 15:28:17 +01:00
|
|
|
ICON_VPAINT_HLT,
|
|
|
|
|
"Vertex Paint",
|
|
|
|
|
"Grease Pencil Vertex Paint Strokes"},
|
2022-02-15 12:32:15 +01:00
|
|
|
{OB_MODE_SCULPT_CURVES, "SCULPT_CURVES", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2009-08-16 05:48:07 +00:00
|
|
|
|
2018-08-21 15:27:29 +02:00
|
|
|
const EnumPropertyItem rna_enum_workspace_object_mode_items[] = {
|
|
|
|
|
{OB_MODE_OBJECT, "OBJECT", ICON_OBJECT_DATAMODE, "Object Mode", ""},
|
|
|
|
|
{OB_MODE_EDIT, "EDIT", ICON_EDITMODE_HLT, "Edit Mode", ""},
|
|
|
|
|
{OB_MODE_POSE, "POSE", ICON_POSE_HLT, "Pose Mode", ""},
|
|
|
|
|
{OB_MODE_SCULPT, "SCULPT", ICON_SCULPTMODE_HLT, "Sculpt Mode", ""},
|
|
|
|
|
{OB_MODE_VERTEX_PAINT, "VERTEX_PAINT", ICON_VPAINT_HLT, "Vertex Paint", ""},
|
|
|
|
|
{OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""},
|
|
|
|
|
{OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""},
|
|
|
|
|
{OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""},
|
2023-07-03 15:15:54 +02:00
|
|
|
{OB_MODE_EDIT_GPENCIL_LEGACY,
|
2018-12-14 16:45:57 +01:00
|
|
|
"EDIT_GPENCIL",
|
|
|
|
|
ICON_EDITMODE_HLT,
|
|
|
|
|
"Grease Pencil Edit Mode",
|
|
|
|
|
"Edit Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_SCULPT_GREASE_PENCIL,
|
|
|
|
|
"SCULPT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_SCULPTMODE_HLT,
|
|
|
|
|
"Grease Pencil Sculpt Mode",
|
|
|
|
|
"Sculpt Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_PAINT_GREASE_PENCIL,
|
|
|
|
|
"PAINT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_GREASEPENCIL,
|
|
|
|
|
"Grease Pencil Draw",
|
|
|
|
|
"Paint Grease Pencil Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_VERTEX_GREASE_PENCIL,
|
|
|
|
|
"VERTEX_GREASE_PENCIL",
|
2020-03-09 16:27:24 +01:00
|
|
|
ICON_VPAINT_HLT,
|
|
|
|
|
"Grease Pencil Vertex Paint",
|
|
|
|
|
"Grease Pencil Vertex Paint Strokes"},
|
2024-10-04 19:20:00 +02:00
|
|
|
{OB_MODE_WEIGHT_GREASE_PENCIL,
|
|
|
|
|
"WEIGHT_GREASE_PENCIL",
|
2018-12-14 16:45:57 +01:00
|
|
|
ICON_WPAINT_HLT,
|
|
|
|
|
"Grease Pencil Weight Paint",
|
|
|
|
|
"Grease Pencil Weight Paint Strokes"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2018-08-21 15:27:29 +02:00
|
|
|
};
|
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_empty_drawtype_items[] = {
|
2018-11-22 15:31:19 +11:00
|
|
|
{OB_PLAINAXES, "PLAIN_AXES", ICON_EMPTY_AXIS, "Plain Axes", ""},
|
|
|
|
|
{OB_ARROWS, "ARROWS", ICON_EMPTY_ARROWS, "Arrows", ""},
|
|
|
|
|
{OB_SINGLE_ARROW, "SINGLE_ARROW", ICON_EMPTY_SINGLE_ARROW, "Single Arrow", ""},
|
|
|
|
|
{OB_CIRCLE, "CIRCLE", ICON_MESH_CIRCLE, "Circle", ""},
|
|
|
|
|
{OB_CUBE, "CUBE", ICON_CUBE, "Cube", ""},
|
|
|
|
|
{OB_EMPTY_SPHERE, "SPHERE", ICON_SPHERE, "Sphere", ""},
|
|
|
|
|
{OB_EMPTY_CONE, "CONE", ICON_CONE, "Cone", ""},
|
|
|
|
|
{OB_EMPTY_IMAGE, "IMAGE", ICON_FILE_IMAGE, "Image", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-10-05 15:48:39 +00:00
|
|
|
};
|
|
|
|
|
|
2018-12-30 15:14:00 +11:00
|
|
|
static const EnumPropertyItem rna_enum_object_empty_image_depth_items[] = {
|
2018-10-31 13:35:53 +01:00
|
|
|
{OB_EMPTY_IMAGE_DEPTH_DEFAULT, "DEFAULT", 0, "Default", ""},
|
|
|
|
|
{OB_EMPTY_IMAGE_DEPTH_FRONT, "FRONT", 0, "Front", ""},
|
|
|
|
|
{OB_EMPTY_IMAGE_DEPTH_BACK, "BACK", 0, "Back", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2018-10-31 13:35:53 +01:00
|
|
|
};
|
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
const EnumPropertyItem rna_enum_object_gpencil_type_items[] = {
|
2024-10-15 13:00:47 +02:00
|
|
|
{GP_EMPTY, "EMPTY", ICON_EMPTY_AXIS, "Blank", "Create an empty Grease Pencil object"},
|
2018-11-22 15:31:19 +11:00
|
|
|
{GP_STROKE, "STROKE", ICON_STROKE, "Stroke", "Create a simple stroke with basic colors"},
|
2024-10-15 13:00:47 +02:00
|
|
|
{GP_MONKEY, "MONKEY", ICON_MONKEY, "Monkey", "Construct a Suzanne Grease Pencil object"},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2024-02-28 16:20:48 +01:00
|
|
|
{GREASE_PENCIL_LINEART_SCENE,
|
|
|
|
|
"LINEART_SCENE",
|
2021-03-16 19:35:53 +01:00
|
|
|
ICON_SCENE_DATA,
|
|
|
|
|
"Scene Line Art",
|
2024-04-15 20:02:38 +02:00
|
|
|
"Quickly set up Line Art for the entire scene"},
|
2024-02-28 16:20:48 +01:00
|
|
|
{GREASE_PENCIL_LINEART_COLLECTION,
|
|
|
|
|
"LINEART_COLLECTION",
|
2021-03-16 19:35:53 +01:00
|
|
|
ICON_OUTLINER_COLLECTION,
|
|
|
|
|
"Collection Line Art",
|
2024-04-15 20:02:38 +02:00
|
|
|
"Quickly set up Line Art for the active collection"},
|
2024-02-28 16:20:48 +01:00
|
|
|
{GREASE_PENCIL_LINEART_OBJECT,
|
|
|
|
|
"LINEART_OBJECT",
|
2021-03-17 08:51:59 -04:00
|
|
|
ICON_OBJECT_DATA,
|
2021-03-16 19:35:53 +01:00
|
|
|
"Object Line Art",
|
2024-04-15 20:02:38 +02:00
|
|
|
"Quickly set up Line Art for the active object"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr}};
|
2012-10-05 15:48:39 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem parent_type_items[] = {
|
2011-05-15 17:59:48 +00:00
|
|
|
{PAROBJECT, "OBJECT", 0, "Object", "The object is parented to an object"},
|
2009-07-14 20:27:28 +00:00
|
|
|
{PARSKEL, "ARMATURE", 0, "Armature", ""},
|
2019-04-17 18:50:53 +02:00
|
|
|
/* PARSKEL reuse will give issues. */
|
|
|
|
|
{PARSKEL, "LATTICE", 0, "Lattice", "The object is parented to a lattice"},
|
2011-05-15 17:59:48 +00:00
|
|
|
{PARVERT1, "VERTEX", 0, "Vertex", "The object is parented to a vertex"},
|
2009-07-14 20:27:28 +00:00
|
|
|
{PARVERT3, "VERTEX_3", 0, "3 Vertices", ""},
|
2011-05-15 17:59:48 +00:00
|
|
|
{PARBONE, "BONE", 0, "Bone", "The object is parented to a bone"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2012-10-05 15:48:39 +00:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
#define INSTANCE_ITEMS_SHARED \
|
2017-06-29 23:22:05 +10:00
|
|
|
{0, "NONE", 0, "None", ""}, \
|
2020-07-22 16:21:33 +10:00
|
|
|
{OB_DUPLIVERTS, "VERTS", 0, "Vertices", "Instantiate child objects on all vertices"}, \
|
2025-10-02 12:55:42 -04:00
|
|
|
{OB_DUPLIFACES, "FACES", 0, "Faces", "Instantiate child objects on all faces"}
|
2017-06-29 23:22:05 +10:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
#define INSTANCE_ITEM_COLLECTION \
|
2025-10-02 12:55:42 -04:00
|
|
|
{OB_DUPLICOLLECTION, "COLLECTION", 0, "Collection", "Enable collection instancing"}
|
2018-11-28 17:49:52 +01:00
|
|
|
static const EnumPropertyItem instance_items[] = {
|
|
|
|
|
INSTANCE_ITEMS_SHARED,
|
|
|
|
|
INSTANCE_ITEM_COLLECTION,
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2017-06-29 23:22:05 +10:00
|
|
|
};
|
|
|
|
|
#ifdef RNA_RUNTIME
|
2018-11-28 17:49:52 +01:00
|
|
|
static EnumPropertyItem instance_items_nogroup[] = {
|
|
|
|
|
INSTANCE_ITEMS_SHARED,
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-12-09 12:43:40 +00:00
|
|
|
};
|
2020-08-04 11:35:44 +02:00
|
|
|
|
2021-05-21 18:25:35 +02:00
|
|
|
static EnumPropertyItem instance_items_empty[] = {
|
|
|
|
|
{0, "NONE", 0, "None", ""},
|
|
|
|
|
INSTANCE_ITEM_COLLECTION,
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2021-05-21 18:25:35 +02:00
|
|
|
};
|
2021-09-09 09:16:03 +02:00
|
|
|
|
|
|
|
|
static EnumPropertyItem instance_items_font[] = {
|
|
|
|
|
{0, "NONE", 0, "None", ""},
|
|
|
|
|
{OB_DUPLIVERTS, "VERTS", 0, "Vertices", "Use Object Font on characters"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2021-09-09 09:16:03 +02:00
|
|
|
};
|
2012-12-13 00:41:23 +00:00
|
|
|
#endif
|
2018-11-28 17:49:52 +01:00
|
|
|
#undef INSTANCE_ITEMS_SHARED
|
|
|
|
|
#undef INSTANCE_ITEM_COLLECTION
|
2012-12-09 12:43:40 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_metaelem_type_items[] = {
|
2010-11-18 04:26:50 +00:00
|
|
|
{MB_BALL, "BALL", ICON_META_BALL, "Ball", ""},
|
|
|
|
|
{MB_TUBE, "CAPSULE", ICON_META_CAPSULE, "Capsule", ""},
|
|
|
|
|
{MB_PLANE, "PLANE", ICON_META_PLANE, "Plane", ""},
|
2019-04-17 18:50:53 +02:00
|
|
|
/* NOTE: typo at original definition! */
|
|
|
|
|
{MB_ELIPSOID, "ELLIPSOID", ICON_META_ELLIPSOID, "Ellipsoid", ""},
|
2010-11-18 04:26:50 +00:00
|
|
|
{MB_CUBE, "CUBE", ICON_META_CUBE, "Cube", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2010-11-18 04:26:50 +00:00
|
|
|
|
2020-01-17 19:14:23 +01:00
|
|
|
const EnumPropertyItem rna_enum_lightprobes_type_items[] = {
|
2023-10-11 19:38:42 +02:00
|
|
|
{LIGHTPROBE_TYPE_SPHERE, "SPHERE", ICON_LIGHTPROBE_SPHERE, "Sphere", ""},
|
|
|
|
|
{LIGHTPROBE_TYPE_PLANE, "PLANE", ICON_LIGHTPROBE_PLANE, "Plane", ""},
|
|
|
|
|
{LIGHTPROBE_TYPE_VOLUME, "VOLUME", ICON_LIGHTPROBE_VOLUME, "Volume", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2020-01-17 19:14:23 +01:00
|
|
|
};
|
|
|
|
|
|
2010-03-23 14:58:36 +00:00
|
|
|
/* used for 2 enums */
|
2025-10-02 12:55:42 -04:00
|
|
|
#define OBTYPE_CU_CURVE {OB_CURVES_LEGACY, "CURVE", ICON_OUTLINER_OB_CURVE, "Curve", ""}
|
|
|
|
|
#define OBTYPE_CU_SURF {OB_SURF, "SURFACE", ICON_OUTLINER_OB_SURFACE, "Surface", ""}
|
|
|
|
|
#define OBTYPE_CU_FONT {OB_FONT, "FONT", ICON_OUTLINER_OB_FONT, "Text", ""}
|
2011-04-21 13:11:51 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_type_items[] = {
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_MESH, "MESH", ICON_OUTLINER_OB_MESH, "Mesh", ""},
|
2010-03-23 14:58:36 +00:00
|
|
|
OBTYPE_CU_CURVE,
|
|
|
|
|
OBTYPE_CU_SURF,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_MBALL, "META", ICON_OUTLINER_OB_META, "Metaball", ""},
|
2010-12-16 09:51:55 +00:00
|
|
|
OBTYPE_CU_FONT,
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
{OB_CURVES, "CURVES", ICON_OUTLINER_OB_CURVES, "Hair Curves", ""},
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_POINTCLOUD, "POINTCLOUD", ICON_OUTLINER_OB_POINTCLOUD, "Point Cloud", ""},
|
|
|
|
|
{OB_VOLUME, "VOLUME", ICON_OUTLINER_OB_VOLUME, "Volume", ""},
|
2025-02-25 10:46:27 +01:00
|
|
|
{OB_GREASE_PENCIL, "GREASEPENCIL", ICON_OUTLINER_OB_GREASEPENCIL, "Grease Pencil", ""},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_ARMATURE, "ARMATURE", ICON_OUTLINER_OB_ARMATURE, "Armature", ""},
|
|
|
|
|
{OB_LATTICE, "LATTICE", ICON_OUTLINER_OB_LATTICE, "Lattice", ""},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_EMPTY, "EMPTY", ICON_OUTLINER_OB_EMPTY, "Empty", ""},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_LAMP, "LIGHT", ICON_OUTLINER_OB_LIGHT, "Light", ""},
|
|
|
|
|
{OB_LIGHTPROBE, "LIGHT_PROBE", ICON_OUTLINER_OB_LIGHTPROBE, "Light Probe", ""},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_CAMERA, "CAMERA", ICON_OUTLINER_OB_CAMERA, "Camera", ""},
|
2022-05-31 14:07:15 +10:00
|
|
|
RNA_ENUM_ITEM_SEPR,
|
2020-09-08 16:30:09 +02:00
|
|
|
{OB_SPEAKER, "SPEAKER", ICON_OUTLINER_OB_SPEAKER, "Speaker", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2009-09-16 17:43:09 +00:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_type_curve_items[] = {
|
2010-03-23 14:58:36 +00:00
|
|
|
OBTYPE_CU_CURVE,
|
|
|
|
|
OBTYPE_CU_SURF,
|
2010-12-16 09:51:55 +00:00
|
|
|
OBTYPE_CU_FONT,
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2010-11-30 20:22:26 +00:00
|
|
|
|
2019-01-16 11:16:15 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_rotation_mode_items[] = {
|
|
|
|
|
{ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order - prone to Gimbal Lock (default)"},
|
|
|
|
|
{ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order - prone to Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order - prone to Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order - prone to Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order - prone to Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order - prone to Gimbal Lock"},
|
|
|
|
|
{ROT_MODE_AXISANGLE,
|
|
|
|
|
"AXIS_ANGLE",
|
|
|
|
|
0,
|
|
|
|
|
"Axis Angle",
|
|
|
|
|
"Axis Angle (W+XYZ), defines a rotation around some axis defined by 3D-Vector"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2019-01-16 11:16:15 +11:00
|
|
|
};
|
|
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
const EnumPropertyItem rna_enum_object_axis_items[] = {
|
2013-01-21 15:41:00 +00:00
|
|
|
{OB_POSX, "POS_X", 0, "+X", ""},
|
|
|
|
|
{OB_POSY, "POS_Y", 0, "+Y", ""},
|
|
|
|
|
{OB_POSZ, "POS_Z", 0, "+Z", ""},
|
|
|
|
|
{OB_NEGX, "NEG_X", 0, "-X", ""},
|
|
|
|
|
{OB_NEGY, "NEG_Y", 0, "-Y", ""},
|
|
|
|
|
{OB_NEGZ, "NEG_Z", 0, "-Z", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2013-01-21 15:41:00 +00:00
|
|
|
};
|
2010-11-30 20:22:26 +00:00
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
2008-12-02 23:45:11 +00:00
|
|
|
|
2024-01-22 15:58:18 +01:00
|
|
|
# include <algorithm>
|
|
|
|
|
|
2024-01-31 13:00:21 -05:00
|
|
|
# include <fmt/format.h>
|
|
|
|
|
|
2025-06-16 15:49:14 +02:00
|
|
|
# include "BLI_bounds.hh"
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
# include "DNA_ID.h"
|
2009-11-11 19:58:30 +00:00
|
|
|
# include "DNA_constraint_types.h"
|
2023-03-13 10:42:51 +01:00
|
|
|
# include "DNA_gpencil_legacy_types.h"
|
2025-02-25 10:46:27 +01:00
|
|
|
# include "DNA_grease_pencil_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
# include "DNA_key_types.h"
|
2011-01-07 09:50:23 +00:00
|
|
|
# include "DNA_lattice_types.h"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "DNA_material_types.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
# include "DNA_node_types.h"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "BLI_math_matrix.h"
|
|
|
|
|
# include "BLI_math_vector.h"
|
|
|
|
|
|
2023-11-16 11:41:55 +01:00
|
|
|
# include "BKE_armature.hh"
|
2023-08-02 22:14:18 +02:00
|
|
|
# include "BKE_brush.hh"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "BKE_camera.h"
|
|
|
|
|
# include "BKE_collection.hh"
|
2009-11-13 16:08:03 +00:00
|
|
|
# include "BKE_constraint.h"
|
2023-11-16 11:41:55 +01:00
|
|
|
# include "BKE_context.hh"
|
|
|
|
|
# include "BKE_curve.hh"
|
2024-01-29 18:57:16 -05:00
|
|
|
# include "BKE_deform.hh"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "BKE_editlattice.h"
|
|
|
|
|
# include "BKE_editmesh.hh"
|
2009-07-02 19:41:31 +00:00
|
|
|
# include "BKE_effect.h"
|
2024-02-10 18:25:14 +01:00
|
|
|
# include "BKE_global.hh"
|
2024-01-30 14:42:07 -05:00
|
|
|
# include "BKE_key.hh"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "BKE_layer.hh"
|
2025-02-07 17:47:16 +01:00
|
|
|
# include "BKE_library.hh"
|
2023-05-24 13:36:13 +02:00
|
|
|
# include "BKE_light_linking.h"
|
2025-01-09 17:26:40 +01:00
|
|
|
# include "BKE_material.hh"
|
2023-08-02 22:14:18 +02:00
|
|
|
# include "BKE_mesh.hh"
|
|
|
|
|
# include "BKE_mesh_wrapper.hh"
|
2023-11-14 09:30:40 +01:00
|
|
|
# include "BKE_modifier.hh"
|
2023-10-09 23:41:53 +02:00
|
|
|
# include "BKE_object.hh"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "BKE_object_deform.h"
|
2016-12-28 17:30:58 +01:00
|
|
|
# include "BKE_particle.h"
|
2024-02-10 19:16:25 +01:00
|
|
|
# include "BKE_scene.hh"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
# include "DEG_depsgraph.hh"
|
|
|
|
|
# include "DEG_depsgraph_build.hh"
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
# include "ED_curve.hh"
|
|
|
|
|
# include "ED_lattice.hh"
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "ED_mesh.hh"
|
2023-08-05 02:57:52 +02:00
|
|
|
# include "ED_object.hh"
|
|
|
|
|
# include "ED_particle.hh"
|
2009-01-01 15:52:51 +00:00
|
|
|
|
2025-01-26 20:08:09 +01:00
|
|
|
# include "DEG_depsgraph_query.hh"
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_internal_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
2009-01-01 15:52:51 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
|
2009-01-01 15:52:51 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_internal_update_draw(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
2018-02-18 19:28:14 +01:00
|
|
|
{
|
2020-04-14 16:08:49 +02:00
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_SHADING);
|
2019-08-23 09:52:12 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->owner_id);
|
2018-02-18 19:28:14 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 06:51:36 +00:00
|
|
|
static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
2009-08-13 11:14:06 +00:00
|
|
|
{
|
2023-08-05 13:46:22 +10:00
|
|
|
/* Don't use compatibility so we get predictable rotation. */
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2024-02-14 16:14:49 +01:00
|
|
|
BKE_object_apply_mat4(ob, ob->object_to_world().ptr(), false, true);
|
2010-06-09 08:24:31 +00:00
|
|
|
rna_Object_internal_update(bmain, scene, ptr);
|
2009-08-13 11:14:06 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_hide_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
2012-06-25 11:43:22 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2019-02-08 13:51:13 -02:00
|
|
|
BKE_main_collection_sync_remap(bmain);
|
2024-02-19 15:54:08 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_SYNC_TO_EVAL);
|
2018-06-18 19:18:02 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id);
|
2012-06-25 11:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_duplicator_visibility_flag_update(Main * /*bmain*/,
|
|
|
|
|
Scene * /*scene*/,
|
2020-04-24 17:23:44 +02:00
|
|
|
PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2020-04-24 17:23:44 +02:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-25 10:46:27 +01:00
|
|
|
static void rna_grease_pencil_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
2018-08-24 23:59:56 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2025-02-25 10:46:27 +01:00
|
|
|
if (ob && ob->type == OB_GREASE_PENCIL) {
|
|
|
|
|
GreasePencil *grease_pencil = static_cast<GreasePencil *>(ob->data);
|
|
|
|
|
DEG_id_tag_update(&grease_pencil->id, ID_RECALC_GEOMETRY);
|
2023-06-14 14:55:44 -04:00
|
|
|
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, nullptr);
|
2020-03-09 16:27:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-14 16:14:49 +01:00
|
|
|
static void rna_Object_matrix_world_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
|
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
|
|
|
|
std::copy_n(ob->object_to_world().base_ptr(), 16, values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_matrix_world_set(PointerRNA *ptr, const float *values)
|
|
|
|
|
{
|
|
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
|
|
|
|
ob->runtime->object_to_world = blender::float4x4(values);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-03 06:51:36 +00:00
|
|
|
static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
|
2010-07-03 17:39:29 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2025-10-02 12:55:42 -04:00
|
|
|
BKE_object_matrix_local_get(ob, (float (*)[4])values);
|
2010-07-03 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 06:51:36 +00:00
|
|
|
static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2014-12-29 15:23:12 +01:00
|
|
|
float local_mat[4][4];
|
2010-07-03 17:39:29 +00:00
|
|
|
|
2022-11-01 12:24:06 +11:00
|
|
|
/* Local-space matrix is truly relative to the parent,
|
2019-04-22 02:48:05 +10:00
|
|
|
* but parameters stored in object are relative to parentinv matrix.
|
|
|
|
|
* Undo the parent inverse part before applying it as local matrix. */
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->parent) {
|
2010-07-03 17:39:29 +00:00
|
|
|
float invmat[4][4];
|
|
|
|
|
invert_m4_m4(invmat, ob->parentinv);
|
2025-10-02 12:55:42 -04:00
|
|
|
mul_m4_m4m4(local_mat, invmat, (float (*)[4])values);
|
2010-07-03 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2025-10-02 12:55:42 -04:00
|
|
|
copy_m4_m4(local_mat, (float (*)[4])values);
|
2010-07-03 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-07 15:57:12 +10:00
|
|
|
/* Don't use compatible so we get predictable rotation, and do not use parenting either,
|
2019-04-22 02:48:05 +10:00
|
|
|
* because it's a local matrix! */
|
2014-12-29 15:23:12 +01:00
|
|
|
BKE_object_apply_mat4(ob, local_mat, false, false);
|
2010-07-03 17:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-15 06:38:07 +00:00
|
|
|
static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2025-10-02 12:55:42 -04:00
|
|
|
BKE_object_to_mat4(ob, (float (*)[4])values);
|
2010-11-15 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16])
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2025-10-02 12:55:42 -04:00
|
|
|
BKE_object_apply_mat4(ob, (float (*)[4])values, false, false);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-30 13:21:49 +11:00
|
|
|
void rna_Object_internal_update_data_impl(PointerRNA *ptr)
|
2009-06-07 13:09:18 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->owner_id);
|
2009-06-07 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
void rna_Object_internal_update_data(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
2020-01-30 13:21:49 +11:00
|
|
|
{
|
|
|
|
|
rna_Object_internal_update_data_impl(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
void rna_Object_internal_update_data_dependency(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
2019-04-24 16:24:53 +03:00
|
|
|
{
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
2020-01-30 13:21:49 +11:00
|
|
|
rna_Object_internal_update_data_impl(ptr);
|
2019-04-24 16:24:53 +03:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_active_shape_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
2009-11-01 00:06:53 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-30 13:21:49 +11:00
|
|
|
if (BKE_object_is_in_editmode(ob)) {
|
2009-11-01 00:06:53 +00:00
|
|
|
/* exit/enter editmode to get new shape */
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (ob->type) {
|
2020-01-30 13:21:49 +11:00
|
|
|
case OB_MESH: {
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
2024-04-18 13:52:20 +02:00
|
|
|
BMEditMesh *em = mesh->runtime->edit_mesh.get();
|
2020-01-30 13:21:49 +11:00
|
|
|
int select_mode = em->selectmode;
|
2018-06-13 16:29:12 +02:00
|
|
|
EDBM_mesh_load(bmain, ob);
|
2020-01-30 13:21:49 +11:00
|
|
|
EDBM_mesh_make(ob, select_mode, true);
|
2024-04-18 13:52:20 +02:00
|
|
|
em = mesh->runtime->edit_mesh.get();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-12-08 16:40:06 -05:00
|
|
|
DEG_id_tag_update(&mesh->id, 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-12-14 12:08:21 +11:00
|
|
|
BKE_editmesh_looptris_and_normals_calc(em);
|
2010-08-10 06:36:42 +00:00
|
|
|
break;
|
2020-01-30 13:21:49 +11:00
|
|
|
}
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2010-08-10 06:36:42 +00:00
|
|
|
case OB_SURF:
|
2018-06-06 15:50:24 +02:00
|
|
|
ED_curve_editnurb_load(bmain, ob);
|
2015-11-18 12:20:28 +11:00
|
|
|
ED_curve_editnurb_make(ob);
|
2010-08-10 06:36:42 +00:00
|
|
|
break;
|
|
|
|
|
case OB_LATTICE:
|
2018-03-19 14:49:59 +01:00
|
|
|
BKE_editlattice_load(ob);
|
|
|
|
|
BKE_editlattice_make(ob);
|
2010-08-10 06:36:42 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-30 13:21:49 +11:00
|
|
|
rna_Object_internal_update_data_impl(ptr);
|
2009-11-01 00:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
2009-04-11 01:43:50 +00:00
|
|
|
{
|
2019-08-23 09:52:12 +02:00
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2019-08-23 09:52:12 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_PARENT, ptr->owner_id);
|
2009-04-11 01:43:50 +00:00
|
|
|
}
|
|
|
|
|
|
2020-12-29 14:43:12 +01:00
|
|
|
void rna_Object_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
rna_Object_internal_update_data_dependency(bmain, scene, ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-14 16:35:25 +01:00
|
|
|
static PointerRNA rna_Object_data_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2022-02-14 16:35:25 +01:00
|
|
|
if (ob->type == OB_MESH) {
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
|
|
|
|
mesh = BKE_mesh_wrapper_ensure_subdivision(mesh);
|
2025-01-27 17:15:54 +01:00
|
|
|
return RNA_id_pointer_create(reinterpret_cast<ID *>(mesh));
|
2022-02-14 16:35:25 +01:00
|
|
|
}
|
2025-01-27 17:15:54 +01:00
|
|
|
return RNA_id_pointer_create(reinterpret_cast<ID *>(ob->data));
|
2022-02-14 16:35:25 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-01 16:38:46 +02:00
|
|
|
static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
|
2009-06-07 13:09:18 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
|
|
|
|
ID *id = static_cast<ID *>(value.data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
if (ob->mode & OB_MODE_EDIT) {
|
2009-06-07 13:09:18 +00:00
|
|
|
return;
|
2014-08-21 17:00:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
/* assigning nullptr only for empties */
|
|
|
|
|
if ((id == nullptr) && (ob->type != OB_EMPTY)) {
|
2014-08-21 17:00:35 +10:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-08-07 12:12:17 +02:00
|
|
|
if (id && ((id->tag & ID_TAG_NO_MAIN) != (ob->id.tag & ID_TAG_NO_MAIN))) {
|
2019-05-17 13:59:59 +02:00
|
|
|
BKE_report(reports,
|
|
|
|
|
RPT_ERROR,
|
2019-06-29 11:12:29 -04:00
|
|
|
"Can only assign evaluated data to evaluated object, or original data to "
|
2019-05-17 13:59:59 +02:00
|
|
|
"original object");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-05-09 16:31:54 +00:00
|
|
|
if (ob->type == OB_EMPTY) {
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->data) {
|
2023-06-14 15:27:59 +02:00
|
|
|
id_us_min(static_cast<ID *>(ob->data));
|
2023-06-14 14:55:44 -04:00
|
|
|
ob->data = nullptr;
|
2011-05-09 16:31:54 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-21 17:00:35 +10:00
|
|
|
if (!id || GS(id->name) == ID_IM) {
|
2011-05-09 16:31:54 +00:00
|
|
|
id_us_plus(id);
|
|
|
|
|
ob->data = id;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (ob->type == OB_MESH) {
|
2023-06-14 15:27:59 +02:00
|
|
|
BKE_mesh_assign_object(G_MAIN, ob, reinterpret_cast<Mesh *>(id));
|
2009-06-07 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-08-12 14:57:19 +00:00
|
|
|
if (ob->data) {
|
2023-06-14 15:27:59 +02:00
|
|
|
id_us_min(static_cast<ID *>(ob->data));
|
2012-08-12 14:57:19 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-21 17:00:35 +10:00
|
|
|
/* no need to type-check here ID. this is done in the _typef() function */
|
|
|
|
|
BLI_assert(OB_DATA_SUPPORT_ID(GS(id->name)));
|
|
|
|
|
id_us_plus(id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
ob->data = id;
|
2025-02-04 17:46:08 +01:00
|
|
|
BKE_object_materials_sync_length(G_MAIN, ob, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-02-18 09:50:29 -06:00
|
|
|
if (GS(id->name) == ID_CU_LEGACY) {
|
2025-05-20 09:26:21 +00:00
|
|
|
BKE_curve_type_test(ob, true);
|
2018-07-19 16:48:21 +02:00
|
|
|
}
|
|
|
|
|
else if (ob->type == OB_ARMATURE) {
|
2023-06-14 15:27:59 +02:00
|
|
|
BKE_pose_rebuild(G_MAIN, ob, static_cast<bArmature *>(ob->data), true);
|
2018-07-19 16:48:21 +02:00
|
|
|
}
|
2009-06-07 13:09:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static StructRNA *rna_Object_data_typef(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-08-12 14:57:19 +00:00
|
|
|
/* keep in sync with OB_DATA_SUPPORT_ID() macro */
|
2012-03-05 23:30:41 +00:00
|
|
|
switch (ob->type) {
|
2011-05-09 16:31:54 +00:00
|
|
|
case OB_EMPTY:
|
|
|
|
|
return &RNA_Image;
|
2009-06-07 13:09:18 +00:00
|
|
|
case OB_MESH:
|
|
|
|
|
return &RNA_Mesh;
|
2022-02-18 09:50:29 -06:00
|
|
|
case OB_CURVES_LEGACY:
|
2009-06-07 13:09:18 +00:00
|
|
|
return &RNA_Curve;
|
|
|
|
|
case OB_SURF:
|
|
|
|
|
return &RNA_Curve;
|
|
|
|
|
case OB_FONT:
|
|
|
|
|
return &RNA_Curve;
|
|
|
|
|
case OB_MBALL:
|
|
|
|
|
return &RNA_MetaBall;
|
2018-06-27 14:41:53 +02:00
|
|
|
case OB_LAMP:
|
|
|
|
|
return &RNA_Light;
|
2009-06-07 13:09:18 +00:00
|
|
|
case OB_CAMERA:
|
|
|
|
|
return &RNA_Camera;
|
|
|
|
|
case OB_LATTICE:
|
|
|
|
|
return &RNA_Lattice;
|
|
|
|
|
case OB_ARMATURE:
|
|
|
|
|
return &RNA_Armature;
|
2011-08-01 11:44:20 +00:00
|
|
|
case OB_SPEAKER:
|
|
|
|
|
return &RNA_Speaker;
|
2017-06-12 20:59:54 +10:00
|
|
|
case OB_LIGHTPROBE:
|
|
|
|
|
return &RNA_LightProbe;
|
2023-03-08 12:35:58 +01:00
|
|
|
case OB_GPENCIL_LEGACY:
|
2025-07-18 12:57:01 +02:00
|
|
|
return &RNA_Annotation;
|
2023-05-30 11:14:16 +02:00
|
|
|
case OB_GREASE_PENCIL:
|
2025-09-29 12:25:23 +02:00
|
|
|
return &RNA_GreasePencil;
|
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use
the name "Curves" to describe the data-block container for multiple
curves. Eventually this will replace the existing "Curve" data-block.
However, it will be a while before the curve data-block can be replaced
so in order to distinguish the two curve types in the UI, "Hair Curves"
will be used, but eventually changed back to "Curves".
This patch renames "hair-related" files, functions, types, and variable
names to this convention. A deep rename is preferred to keep code
consistent and to avoid any "hair" terminology from leaking, since the
new data-block is meant for all curve types, not just hair use cases.
The downside of this naming is that the difference between "Curve"
and "Curves" has become important. That was considered during
design discussons and deemed acceptable, especially given the
non-permanent nature of the somewhat common conflict.
Some points of interest:
- All DNA compatibility is lost, just like rBf59767ff9729.
- I renamed `ID_HA` to `ID_CV` so there is no complete mismatch.
- `hair_curves` is used where necessary to distinguish from the
existing "curves" plural.
- I didn't rename any of the cycles/rendering code function names,
since that is also used by the old hair particle system.
Differential Revision: https://developer.blender.org/D14007
2022-02-07 11:55:54 -06:00
|
|
|
case OB_CURVES:
|
|
|
|
|
return &RNA_Curves;
|
2020-03-17 14:41:48 +01:00
|
|
|
case OB_POINTCLOUD:
|
|
|
|
|
return &RNA_PointCloud;
|
|
|
|
|
case OB_VOLUME:
|
|
|
|
|
return &RNA_Volume;
|
2009-06-07 13:09:18 +00:00
|
|
|
default:
|
|
|
|
|
return &RNA_ID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-01 16:38:46 +02:00
|
|
|
static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
|
2009-07-14 20:27:28 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
|
|
|
|
Object *par = static_cast<Object *>(value.data);
|
2017-05-27 15:34:55 -04:00
|
|
|
|
2012-05-06 12:13:45 +00:00
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::parent_set(ob, par, ob->partype, ob->parsubstr);
|
2012-05-06 05:03:58 +00:00
|
|
|
}
|
2009-07-14 20:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-01 12:21:00 +02:00
|
|
|
static bool rna_Object_parent_override_apply(Main *bmain,
|
2023-07-31 15:17:19 +02:00
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
|
|
|
|
|
PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
|
|
|
|
|
PropertyRNA *prop_src = rnaapply_ctx.prop_src;
|
|
|
|
|
const int len_dst = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_src = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_storage = rnaapply_ctx.len_storage;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
2019-08-14 17:25:40 +02:00
|
|
|
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
|
2023-05-02 16:13:02 +02:00
|
|
|
BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE &&
|
2019-08-27 16:28:41 +02:00
|
|
|
"Unsupported RNA override operation on object parent pointer");
|
2019-08-14 17:25:40 +02:00
|
|
|
UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
|
|
|
|
|
|
2019-08-27 16:28:41 +02:00
|
|
|
/* We need a special handling here because setting parent resets invert parent matrix,
|
2019-08-14 17:25:40 +02:00
|
|
|
* which is evil in our case. */
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr_dst->data);
|
|
|
|
|
Object *parent_dst = static_cast<Object *>(RNA_property_pointer_get(ptr_dst, prop_dst).data);
|
|
|
|
|
Object *parent_src = static_cast<Object *>(RNA_property_pointer_get(ptr_src, prop_src).data);
|
2019-08-14 17:25:40 +02:00
|
|
|
|
|
|
|
|
if (parent_src == parent_dst) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (parent_src == nullptr) {
|
2019-08-14 17:25:40 +02:00
|
|
|
/* The only case where we do want default behavior (with matrix reset). */
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::parent_set(ob, parent_src, ob->partype, ob->parsubstr);
|
2019-08-14 17:25:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ob->parent = parent_src;
|
|
|
|
|
}
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
|
2019-08-14 17:25:40 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-14 20:27:28 +00:00
|
|
|
static void rna_Object_parent_type_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2009-07-14 20:27:28 +00:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
/* Skip if type did not change (otherwise we loose parent inverse in
|
|
|
|
|
* blender::ed::object::parent_set). */
|
2022-08-24 13:39:22 +02:00
|
|
|
if (ob->partype == value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::parent_set(ob, ob->parent, value, ob->parsubstr);
|
2009-07-14 20:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-04 17:06:05 +02:00
|
|
|
static bool rna_Object_parent_type_override_apply(Main *bmain,
|
2023-07-31 15:17:19 +02:00
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
|
|
|
|
|
PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
|
|
|
|
|
PropertyRNA *prop_src = rnaapply_ctx.prop_src;
|
|
|
|
|
const int len_dst = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_src = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_storage = rnaapply_ctx.len_storage;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
2023-07-04 17:06:05 +02:00
|
|
|
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
|
|
|
|
|
BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE &&
|
|
|
|
|
"Unsupported RNA override operation on object parent pointer");
|
|
|
|
|
UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
|
|
|
|
|
|
|
|
|
|
/* We need a special handling here because setting parent resets invert parent matrix,
|
|
|
|
|
* which is evil in our case. */
|
|
|
|
|
Object *ob = (Object *)(ptr_dst->data);
|
2023-10-04 14:43:42 +02:00
|
|
|
const int parent_type_dst = RNA_property_enum_get(ptr_dst, prop_dst);
|
|
|
|
|
const int parent_type_src = RNA_property_enum_get(ptr_src, prop_src);
|
2023-07-04 17:06:05 +02:00
|
|
|
|
|
|
|
|
if (parent_type_dst == parent_type_src) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ob->partype = parent_type_src;
|
|
|
|
|
RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static const EnumPropertyItem *rna_Object_parent_type_itemf(bContext * /*C*/,
|
2019-01-02 17:03:45 +11:00
|
|
|
PointerRNA *ptr,
|
2023-06-14 15:27:59 +02:00
|
|
|
PropertyRNA * /*prop*/,
|
2019-01-02 17:03:45 +11:00
|
|
|
bool *r_free)
|
2009-07-14 20:27:28 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2023-06-14 14:55:44 -04:00
|
|
|
EnumPropertyItem *item = nullptr;
|
2012-03-05 23:30:41 +00:00
|
|
|
int totitem = 0;
|
2009-07-14 20:27:28 +00:00
|
|
|
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->parent) {
|
|
|
|
|
Object *par = ob->parent;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2015-06-23 17:35:55 +02:00
|
|
|
if (par->type == OB_LATTICE) {
|
2012-03-18 09:27:36 +00:00
|
|
|
/* special hack: prevents this overriding others */
|
2015-07-25 10:39:04 +02:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, &parent_type_items[2], PARSKEL);
|
2013-07-09 13:50:22 +00:00
|
|
|
}
|
2012-03-05 23:30:41 +00:00
|
|
|
else if (par->type == OB_ARMATURE) {
|
2018-09-24 17:27:41 +02:00
|
|
|
/* special hack: prevents this being overridden */
|
2015-07-25 10:39:04 +02:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, &parent_type_items[1], PARSKEL);
|
2009-07-14 20:27:28 +00:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARBONE);
|
|
|
|
|
}
|
2013-07-09 13:50:22 +00:00
|
|
|
|
2013-09-01 22:38:41 +00:00
|
|
|
if (OB_TYPE_SUPPORT_PARVERT(par->type)) {
|
2009-07-14 20:27:28 +00:00
|
|
|
RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT1);
|
|
|
|
|
RNA_enum_items_add_value(&item, &totitem, parent_type_items, PARVERT3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RNA_enum_item_end(&item, &totitem);
|
2014-01-04 18:08:43 +11:00
|
|
|
*r_free = true;
|
2009-07-14 20:27:28 +00:00
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-03 18:58:41 +02:00
|
|
|
static void rna_Object_empty_display_type_set(PointerRNA *ptr, int value)
|
2014-01-13 21:57:05 +01:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2014-01-13 21:57:05 +01:00
|
|
|
|
2014-02-03 13:55:26 +11:00
|
|
|
BKE_object_empty_draw_type_set(ob, value);
|
2014-01-13 21:57:05 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-14 20:27:28 +00:00
|
|
|
static void rna_Object_parent_bone_set(PointerRNA *ptr, const char *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2009-07-14 20:27:28 +00:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::parent_set(ob, ob->parent, ob->partype, value);
|
2009-07-14 20:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-04 17:06:05 +02:00
|
|
|
static bool rna_Object_parent_bone_override_apply(Main *bmain,
|
2023-07-31 15:17:19 +02:00
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
|
|
|
|
|
PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
|
|
|
|
|
PropertyRNA *prop_src = rnaapply_ctx.prop_src;
|
|
|
|
|
const int len_dst = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_src = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_storage = rnaapply_ctx.len_storage;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
2023-07-04 17:06:05 +02:00
|
|
|
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
|
|
|
|
|
BLI_assert(opop->operation == LIBOVERRIDE_OP_REPLACE &&
|
|
|
|
|
"Unsupported RNA override operation on object parent bone property");
|
|
|
|
|
UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
|
|
|
|
|
|
|
|
|
|
/* We need a special handling here because setting parent resets invert parent matrix,
|
|
|
|
|
* which is evil in our case. */
|
|
|
|
|
Object *ob = (Object *)(ptr_dst->data);
|
|
|
|
|
char parent_bone_dst[MAX_ID_NAME - 2];
|
|
|
|
|
RNA_property_string_get(ptr_dst, prop_dst, parent_bone_dst);
|
|
|
|
|
char parent_bone_src[MAX_ID_NAME - 2];
|
|
|
|
|
RNA_property_string_get(ptr_src, prop_src, parent_bone_src);
|
|
|
|
|
|
|
|
|
|
if (STREQ(parent_bone_src, parent_bone_dst)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
STRNCPY(ob->parsubstr, parent_bone_src);
|
|
|
|
|
RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static const EnumPropertyItem *rna_Object_instance_type_itemf(bContext * /*C*/,
|
2017-06-29 23:22:05 +10:00
|
|
|
PointerRNA *ptr,
|
2023-06-14 15:27:59 +02:00
|
|
|
PropertyRNA * /*prop*/,
|
|
|
|
|
bool * /*r_free*/)
|
2017-06-29 23:22:05 +10:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2017-10-18 17:09:41 +11:00
|
|
|
const EnumPropertyItem *item;
|
2017-06-29 23:22:05 +10:00
|
|
|
|
|
|
|
|
if (ob->type == OB_EMPTY) {
|
2021-05-21 18:25:35 +02:00
|
|
|
item = instance_items_empty;
|
2017-06-29 23:22:05 +10:00
|
|
|
}
|
2021-09-09 09:16:03 +02:00
|
|
|
else if (ob->type == OB_FONT) {
|
|
|
|
|
item = instance_items_font;
|
|
|
|
|
}
|
2017-06-29 23:22:05 +10:00
|
|
|
else {
|
2018-11-28 17:49:52 +01:00
|
|
|
item = instance_items_nogroup;
|
2017-06-29 23:22:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-20 18:06:09 +10:00
|
|
|
static void rna_Object_dup_collection_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2010-12-19 10:38:02 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
|
|
|
|
Collection *grp = static_cast<Collection *>(value.data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-30 20:09:02 +10:00
|
|
|
/* Must not let this be set if the object belongs in this group already,
|
2023-02-12 14:37:16 +11:00
|
|
|
* thus causing a cycle/infinite-recursion leading to crashes on load #25298. */
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
if (BKE_collection_has_object_recursive(grp, ob) == 0) {
|
2017-06-29 23:22:05 +10:00
|
|
|
if (ob->type == OB_EMPTY) {
|
2019-02-17 19:00:54 +11:00
|
|
|
id_us_min(&ob->instance_collection->id);
|
|
|
|
|
ob->instance_collection = grp;
|
|
|
|
|
id_us_plus(&ob->instance_collection->id);
|
2017-06-29 23:22:05 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2023-06-14 14:55:44 -04:00
|
|
|
BKE_report(nullptr, RPT_ERROR, "Only empty objects support collection instances");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-06-29 23:22:05 +10:00
|
|
|
}
|
2015-10-16 20:55:23 +11:00
|
|
|
else {
|
2022-12-15 09:34:22 +11:00
|
|
|
BKE_report(
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
2022-12-15 09:34:22 +11:00
|
|
|
RPT_ERROR,
|
|
|
|
|
"Cannot set instance-collection as object belongs in collection being instanced, thus "
|
|
|
|
|
"causing a cycle");
|
2015-10-16 20:55:23 +11:00
|
|
|
}
|
2010-12-19 10:38:02 +00:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 15:43:57 +02:00
|
|
|
static void rna_Object_vertex_groups_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data);
|
|
|
|
|
rna_Object_internal_update_data_impl(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 12:10:34 -04:00
|
|
|
static void rna_Object_vertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
iter->valid = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);
|
2023-06-14 14:55:44 -04:00
|
|
|
iter->valid = defbase != nullptr;
|
2021-07-13 12:10:34 -04:00
|
|
|
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
rna_iterator_listbase_begin(iter, ptr, defbase, nullptr);
|
2021-07-13 12:10:34 -04:00
|
|
|
}
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value)
|
2011-06-05 04:52:32 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bDeformGroup *dg = static_cast<bDeformGroup *>(ptr->data);
|
2024-10-16 10:27:09 +02:00
|
|
|
BKE_object_defgroup_set_name(dg, ob, value);
|
2011-06-05 04:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
static int rna_VertexGroup_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2009-01-01 20:44:40 +00:00
|
|
|
|
2021-07-13 12:10:34 -04:00
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
|
|
|
|
return BLI_findindex(defbase, ptr->data);
|
2009-01-01 20:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Object_active_vertex_group_get(PointerRNA *ptr)
|
2009-01-01 20:44:40 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return PointerRNA_NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
|
|
|
|
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(
|
|
|
|
|
*ptr, &RNA_VertexGroup, BLI_findlink(defbase, BKE_object_defgroup_active_index_get(ob) - 1));
|
2009-01-01 20:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 22:14:38 -03:00
|
|
|
static void rna_Object_active_vertex_group_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList *reports)
|
2020-03-27 22:14:38 -03:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
|
|
|
|
|
|
|
|
|
int index = BLI_findindex(defbase, value.data);
|
2020-03-27 22:14:38 -03:00
|
|
|
if (index == -1) {
|
|
|
|
|
BKE_reportf(reports,
|
|
|
|
|
RPT_ERROR,
|
|
|
|
|
"VertexGroup '%s' not found in object '%s'",
|
2023-06-14 15:27:59 +02:00
|
|
|
(static_cast<bDeformGroup *>(value.data))->name,
|
2020-03-27 22:14:38 -03:00
|
|
|
ob->id.name + 2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 12:10:34 -04:00
|
|
|
BKE_object_defgroup_active_index_set(ob, index + 1);
|
2020-03-27 22:14:38 -03:00
|
|
|
}
|
|
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return BKE_object_defgroup_active_index_get(ob) - 1;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_object_defgroup_active_index_set(ob, value + 1);
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_Object_active_vertex_group_index_range(
|
2023-06-14 15:27:59 +02:00
|
|
|
PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
|
2009-07-02 03:32:57 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = 0;
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
*max = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
|
|
|
|
*max = max_ii(0, BLI_listbase_count(defbase) - 1);
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-04 19:25:24 +00:00
|
|
|
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
value[0] = '\0';
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2021-07-13 12:10:34 -04:00
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
2023-06-14 15:27:59 +02:00
|
|
|
const bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, index - 1));
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (dg) {
|
2023-05-04 10:26:22 +10:00
|
|
|
strcpy(value, dg->name);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
value[0] = '\0';
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2021-07-13 12:10:34 -04:00
|
|
|
const ListBase *defbase = BKE_object_defgroup_list(ob);
|
2023-06-14 15:27:59 +02:00
|
|
|
bDeformGroup *dg = static_cast<bDeformGroup *>(BLI_findlink(defbase, index - 1));
|
2012-05-12 11:01:29 +00:00
|
|
|
return (dg) ? strlen(dg->name) : 0;
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
*index = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 12:50:56 +11:00
|
|
|
*index = BKE_object_defgroup_name_index(ob, value) + 1;
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void rna_object_vgroup_name_set(PointerRNA *ptr,
|
|
|
|
|
const char *value,
|
|
|
|
|
char *result,
|
|
|
|
|
int result_maxncpy)
|
2009-01-04 19:25:24 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-07-13 12:10:34 -04:00
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
result[0] = '\0';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-06 12:50:56 +11:00
|
|
|
bDeformGroup *dg = BKE_object_defgroup_find_name(ob, value);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (dg) {
|
2019-04-17 18:50:53 +02:00
|
|
|
/* No need for BLI_strncpy_utf8, since this matches an existing group. */
|
2023-05-07 15:22:58 +10:00
|
|
|
BLI_strncpy(result, value, result_maxncpy);
|
2010-08-22 14:15:28 +00:00
|
|
|
return;
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
result[0] = '\0';
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void rna_object_uvlayer_name_set(PointerRNA *ptr,
|
|
|
|
|
const char *value,
|
|
|
|
|
char *result,
|
|
|
|
|
int result_maxncpy)
|
2009-01-04 19:25:24 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh;
|
2009-01-04 19:25:24 +00:00
|
|
|
CustomDataLayer *layer;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->type == OB_MESH && ob->data) {
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh = static_cast<Mesh *>(ob->data);
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2023-12-19 20:38:59 -05:00
|
|
|
for (a = 0; a < mesh->corner_data.totlayer; a++) {
|
|
|
|
|
layer = &mesh->corner_data.layers[a];
|
2009-01-04 19:25:24 +00:00
|
|
|
|
Mesh: Move UV layers to generic attributes
Currently the `MLoopUV` struct stores UV coordinates and flags related
to editing UV maps in the UV editor. This patch changes the coordinates
to use the generic 2D vector type, and moves the flags into three
separate boolean attributes. This follows the design in T95965, with
the ultimate intention of simplifying code and improving performance.
Importantly, the change allows exporters and renderers to use UVs
"touched" by geometry nodes, which only creates generic attributes.
It also allows geometry nodes to create "proper" UV maps from scratch,
though only with the Store Named Attribute node for now.
The new design considers any 2D vector attribute on the corner domain
to be a UV map. In the future, they might be distinguished from regular
2D vectors with attribute metadata, which may be helpful because they
are often interpolated differently.
Most of the code changes deal with passing around UV BMesh custom data
offsets and tracking the boolean "sublayers". The boolean layers are
use the following prefixes for attribute names: vert selection: `.vs.`,
edge selection: `.es.`, pinning: `.pn.`. Currently these are short to
avoid using up the maximum length of attribute names. To accommodate
for these 4 extra characters, the name length limit is enlarged to 68
bytes, while the maximum user settable name length is still 64 bytes.
Unfortunately Python/RNA API access to the UV flag data becomes slower.
Accessing the boolean layers directly is be better for performance in
general.
Like the other mesh SoA refactors, backward and forward compatibility
aren't affected, and won't be changed until 4.0. We pay for that by
making mesh reading and writing more expensive with conversions.
Resolves T85962
Differential Revision: https://developer.blender.org/D14365
2023-01-10 00:47:04 -05:00
|
|
|
if (layer->type == CD_PROP_FLOAT2 && STREQ(layer->name, value)) {
|
2023-05-07 15:22:58 +10:00
|
|
|
BLI_strncpy(result, value, result_maxncpy);
|
2009-01-04 19:25:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
result[0] = '\0';
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-07 15:22:58 +10:00
|
|
|
void rna_object_vcollayer_name_set(PointerRNA *ptr,
|
|
|
|
|
const char *value,
|
|
|
|
|
char *result,
|
|
|
|
|
int result_maxncpy)
|
2009-01-04 19:25:24 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh;
|
2009-01-04 19:25:24 +00:00
|
|
|
CustomDataLayer *layer;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->type == OB_MESH && ob->data) {
|
2023-12-08 16:40:06 -05:00
|
|
|
mesh = static_cast<Mesh *>(ob->data);
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2023-12-08 16:40:06 -05:00
|
|
|
for (a = 0; a < mesh->fdata_legacy.totlayer; a++) {
|
|
|
|
|
layer = &mesh->fdata_legacy.layers[a];
|
2009-01-04 19:25:24 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (layer->type == CD_MCOL && STREQ(layer->name, value)) {
|
2023-05-07 15:22:58 +10:00
|
|
|
BLI_strncpy(result, value, result_maxncpy);
|
2009-01-04 19:25:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
result[0] = '\0';
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-02 03:32:57 +00:00
|
|
|
static int rna_Object_active_material_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2024-01-22 15:58:18 +01:00
|
|
|
return std::max<int>(ob->actcol - 1, 0);
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_active_material_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2024-04-12 17:35:22 +02:00
|
|
|
|
|
|
|
|
value = std::max(std::min(value, ob->totcol - 1), 0);
|
2012-05-12 11:01:29 +00:00
|
|
|
ob->actcol = value + 1;
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (ob->type == OB_MESH) {
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2024-03-21 23:18:49 +01:00
|
|
|
if (mesh->runtime->edit_mesh) {
|
|
|
|
|
mesh->runtime->edit_mesh->mat_nr = value;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_Object_active_material_index_range(
|
2023-06-14 15:27:59 +02:00
|
|
|
PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
|
2009-01-02 13:47:33 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = 0;
|
2012-11-07 12:31:05 +00:00
|
|
|
*max = max_ii(ob->totcol - 1, 0);
|
2009-01-02 13:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-20 13:02:33 +00:00
|
|
|
/* returns active base material */
|
2009-02-02 19:57:57 +00:00
|
|
|
static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
|
2009-01-04 19:25:24 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-28 18:54:02 +00:00
|
|
|
Material *ma;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
ma = (ob->totcol) ? BKE_object_material_get(ob, ob->actcol) : nullptr;
|
2025-01-27 17:15:54 +01:00
|
|
|
return RNA_id_pointer_create(reinterpret_cast<ID *>(ma));
|
2009-07-28 18:54:02 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-20 18:06:09 +10:00
|
|
|
static void rna_Object_active_material_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2009-07-28 18:54:02 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-28 18:54:02 +00:00
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
DEG_id_tag_update(static_cast<ID *>(value.data), 0);
|
2018-11-09 10:44:02 -02:00
|
|
|
BLI_assert(BKE_id_is_in_global_main(&ob->id));
|
2023-06-14 15:27:59 +02:00
|
|
|
BLI_assert(BKE_id_is_in_global_main(static_cast<ID *>(value.data)));
|
|
|
|
|
BKE_object_material_assign(
|
|
|
|
|
G_MAIN, ob, static_cast<Material *>(value.data), ob->actcol, BKE_MAT_ASSIGN_EXISTING);
|
2009-01-04 19:25:24 +00:00
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_active_material_editable(const PointerRNA *ptr, const char ** /*r_info*/)
|
2014-05-29 16:16:31 +10:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2014-05-29 16:16:31 +10:00
|
|
|
bool is_editable;
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if ((ob->matbits == nullptr) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
|
2024-05-16 14:53:09 +02:00
|
|
|
is_editable = ID_IS_EDITABLE(ob);
|
2014-05-29 16:16:31 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2024-05-16 14:53:09 +02:00
|
|
|
is_editable = ob->data ? ID_IS_EDITABLE(ob->data) : false;
|
2014-05-29 16:16:31 +10:00
|
|
|
}
|
|
|
|
|
|
2023-06-15 13:46:04 +10:00
|
|
|
return is_editable ? int(PROP_EDITABLE) : 0;
|
2014-05-29 16:16:31 +10:00
|
|
|
}
|
|
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
static void rna_Object_active_particle_system_index_range(
|
2023-06-14 15:27:59 +02:00
|
|
|
PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2016-12-28 17:30:58 +01:00
|
|
|
*min = 0;
|
|
|
|
|
*max = max_ii(0, BLI_listbase_count(&ob->particlesystem) - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2016-12-28 17:30:58 +01:00
|
|
|
return psys_get_current_num(ob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2016-12-28 17:30:58 +01:00
|
|
|
psys_set_current_num(ob, value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_particle_update(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
|
2016-12-28 17:30:58 +01:00
|
|
|
{
|
2017-07-21 11:53:13 +02:00
|
|
|
/* TODO: Disabled for now, because bContext is not available. */
|
|
|
|
|
# if 0
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-06-14 14:55:44 -04:00
|
|
|
PE_current_changed(nullptr, scene, ob);
|
2017-07-21 15:54:42 +02:00
|
|
|
# else
|
|
|
|
|
(void)scene;
|
|
|
|
|
(void)ptr;
|
2017-07-21 11:53:13 +02:00
|
|
|
# endif
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* rotation - axis-angle */
|
|
|
|
|
static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* for now, assume that rotation mode is axis-angle */
|
2012-03-05 23:30:41 +00:00
|
|
|
value[0] = ob->rotAngle;
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_v3_v3(&value[1], ob->rotAxis);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* rotation - axis-angle */
|
|
|
|
|
static void rna_Object_rotation_axis_angle_set(PointerRNA *ptr, const float *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* for now, assume that rotation mode is axis-angle */
|
2012-03-05 23:30:41 +00:00
|
|
|
ob->rotAngle = value[0];
|
2015-01-01 23:26:03 +11:00
|
|
|
copy_v3_v3(ob->rotAxis, &value[1]);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
/* TODO: validate axis? */
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* use API Method for conversions... */
|
|
|
|
|
BKE_rotMode_change_values(
|
2023-07-14 12:23:37 +10:00
|
|
|
ob->quat, ob->rot, ob->rotAxis, &ob->rotAngle, ob->rotmode, short(value));
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* finally, set the new rotation type */
|
2012-03-05 23:30:41 +00:00
|
|
|
ob->rotmode = value;
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-04 23:14:20 +00:00
|
|
|
static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
|
2009-10-22 23:22:05 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2023-11-15 11:03:04 +01:00
|
|
|
BKE_object_dimensions_eval_cached_get(ob, value);
|
2009-10-22 23:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-05 16:33:38 +01:00
|
|
|
static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2019-01-05 16:33:38 +01:00
|
|
|
BKE_object_dimensions_set(ob, value, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_location_editable(const PointerRNA *ptr, int index)
|
2009-11-25 12:00:31 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
/* only if the axis in question is locked, not editable... */
|
2019-06-04 00:21:57 +10:00
|
|
|
if ((index == 0) && (ob->protectflag & OB_LOCK_LOCX)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 1) && (ob->protectflag & OB_LOCK_LOCY)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 2) && (ob->protectflag & OB_LOCK_LOCZ)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-11-25 12:00:31 +00:00
|
|
|
return PROP_EDITABLE;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-11-25 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_scale_editable(const PointerRNA *ptr, int index)
|
2009-11-25 12:00:31 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
/* only if the axis in question is locked, not editable... */
|
2019-06-04 00:21:57 +10:00
|
|
|
if ((index == 0) && (ob->protectflag & OB_LOCK_SCALEX)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 1) && (ob->protectflag & OB_LOCK_SCALEY)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 2) && (ob->protectflag & OB_LOCK_SCALEZ)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-11-25 12:00:31 +00:00
|
|
|
return PROP_EDITABLE;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-11-25 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_rotation_euler_editable(const PointerRNA *ptr, int index)
|
2009-11-25 12:00:31 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
/* only if the axis in question is locked, not editable... */
|
2019-06-04 00:21:57 +10:00
|
|
|
if ((index == 0) && (ob->protectflag & OB_LOCK_ROTX)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTY)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTZ)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2009-11-25 12:00:31 +00:00
|
|
|
return PROP_EDITABLE;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-11-25 12:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_rotation_4d_editable(const PointerRNA *ptr, int index)
|
2009-11-25 12:00:31 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = static_cast<Object *>(ptr->data);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
/* only consider locks if locking components individually... */
|
|
|
|
|
if (ob->protectflag & OB_LOCK_ROT4D) {
|
|
|
|
|
/* only if the axis in question is locked, not editable... */
|
2019-06-04 00:21:57 +10:00
|
|
|
if ((index == 0) && (ob->protectflag & OB_LOCK_ROTW)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 1) && (ob->protectflag & OB_LOCK_ROTX)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 2) && (ob->protectflag & OB_LOCK_ROTY)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else if ((index == 3) && (ob->protectflag & OB_LOCK_ROTZ)) {
|
2009-11-25 12:00:31 +00:00
|
|
|
return 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-11-25 12:00:31 +00:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-11-25 12:00:31 +00:00
|
|
|
return PROP_EDITABLE;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-25 12:23:11 +02:00
|
|
|
static int rna_MaterialSlot_index(const PointerRNA *ptr)
|
2021-05-19 10:23:09 +02:00
|
|
|
{
|
2021-08-25 13:09:44 +02:00
|
|
|
/* There is an offset, so that `ptr->data` is not null and unique across IDs. */
|
2023-07-14 12:23:37 +10:00
|
|
|
return uintptr_t(ptr->data) - uintptr_t(ptr->owner_id);
|
2021-05-19 10:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-25 12:23:11 +02:00
|
|
|
static int rna_MaterialSlot_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return rna_MaterialSlot_index(ptr);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_MaterialSlot_material_editable(const PointerRNA *ptr, const char ** /*r_info*/)
|
2018-06-11 19:28:12 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-05-19 10:23:09 +02:00
|
|
|
const int index = rna_MaterialSlot_index(ptr);
|
2018-06-11 19:28:12 +02:00
|
|
|
bool is_editable;
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if ((ob->matbits == nullptr) || ob->matbits[index]) {
|
2024-05-16 14:53:09 +02:00
|
|
|
is_editable = ID_IS_EDITABLE(ob);
|
2018-06-11 19:28:12 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2024-05-16 14:53:09 +02:00
|
|
|
is_editable = ob->data ? ID_IS_EDITABLE(ob->data) : false;
|
2018-06-11 19:28:12 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-15 13:46:04 +10:00
|
|
|
return is_editable ? int(PROP_EDITABLE) : 0;
|
2018-06-11 19:28:12 +02:00
|
|
|
}
|
2009-10-22 23:22:05 +00:00
|
|
|
|
2009-06-03 23:22:43 +00:00
|
|
|
static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
|
2009-01-02 16:58:09 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-06-03 23:22:43 +00:00
|
|
|
Material *ma;
|
2021-05-19 10:23:09 +02:00
|
|
|
const int index = rna_MaterialSlot_index(ptr);
|
2009-06-03 23:22:43 +00:00
|
|
|
|
2025-05-02 15:08:29 +02:00
|
|
|
if (DEG_is_evaluated(ob)) {
|
2021-05-19 10:23:09 +02:00
|
|
|
ma = BKE_object_material_get_eval(ob, index + 1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ma = BKE_object_material_get(ob, index + 1);
|
|
|
|
|
}
|
2025-01-27 17:15:54 +01:00
|
|
|
return RNA_id_pointer_create(reinterpret_cast<ID *>(ma));
|
2009-01-02 16:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-20 18:06:09 +10:00
|
|
|
static void rna_MaterialSlot_material_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2009-01-02 16:58:09 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-05-19 10:23:09 +02:00
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
2009-06-03 23:22:43 +00:00
|
|
|
|
2018-11-09 10:44:02 -02:00
|
|
|
BLI_assert(BKE_id_is_in_global_main(&ob->id));
|
2023-06-14 15:27:59 +02:00
|
|
|
BLI_assert(BKE_id_is_in_global_main(static_cast<ID *>(value.data)));
|
|
|
|
|
BKE_object_material_assign(
|
|
|
|
|
G_MAIN, ob, static_cast<Material *>(value.data), index + 1, BKE_MAT_ASSIGN_EXISTING);
|
2009-06-03 23:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
static bool rna_MaterialSlot_material_poll(PointerRNA *ptr, PointerRNA value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
Material *ma = static_cast<Material *>(value.data);
|
2018-07-31 10:22:19 +02:00
|
|
|
|
2025-02-25 10:46:27 +01:00
|
|
|
if (ELEM(ob->type, OB_GREASE_PENCIL)) {
|
2018-07-31 10:22:19 +02:00
|
|
|
/* GP Materials only */
|
2023-06-14 14:55:44 -04:00
|
|
|
return (ma->gp_style != nullptr);
|
2018-07-31 10:22:19 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Everything except GP materials */
|
2023-06-14 14:55:44 -04:00
|
|
|
return (ma->gp_style == nullptr);
|
2018-07-31 10:22:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:22:43 +00:00
|
|
|
static int rna_MaterialSlot_link_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-05-19 10:23:09 +02:00
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
|
|
|
|
if (index < ob->totcol) {
|
|
|
|
|
return ob->matbits[index] != 0;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2009-06-03 23:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_MaterialSlot_link_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-05-19 10:23:09 +02:00
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (value) {
|
|
|
|
|
ob->matbits[index] = 1;
|
2021-02-05 16:23:34 +11:00
|
|
|
/* DEPRECATED */
|
|
|
|
|
// ob->colbits |= (1 << index);
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
ob->matbits[index] = 0;
|
2021-02-05 16:23:34 +11:00
|
|
|
/* DEPRECATED */
|
|
|
|
|
// ob->colbits &= ~(1 << index);
|
2009-07-13 00:40:20 +00:00
|
|
|
}
|
2009-06-03 23:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_MaterialSlot_name_length(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-06-03 23:22:43 +00:00
|
|
|
Material *ma;
|
2021-05-19 10:23:09 +02:00
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
2009-06-03 23:22:43 +00:00
|
|
|
|
2020-02-05 11:23:58 +01:00
|
|
|
ma = BKE_object_material_get(ob, index + 1);
|
2009-06-03 23:22:43 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ma) {
|
2012-05-12 11:01:29 +00:00
|
|
|
return strlen(ma->id.name + 2);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2009-06-07 13:09:18 +00:00
|
|
|
return 0;
|
2009-06-03 23:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-20 13:23:30 +10:00
|
|
|
static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *value)
|
2009-06-03 23:22:43 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-06-03 23:22:43 +00:00
|
|
|
Material *ma;
|
2021-05-19 10:23:09 +02:00
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
2009-06-03 23:22:43 +00:00
|
|
|
|
2020-02-05 11:23:58 +01:00
|
|
|
ma = BKE_object_material_get(ob, index + 1);
|
2009-06-07 13:09:18 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ma) {
|
2023-06-20 13:23:30 +10:00
|
|
|
strcpy(value, ma->id.name + 2);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2023-06-20 13:23:30 +10:00
|
|
|
value[0] = '\0';
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2009-01-02 16:58:09 +00:00
|
|
|
}
|
|
|
|
|
|
2010-10-05 11:55:54 +00:00
|
|
|
static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
rna_Object_internal_update(bmain, scene, ptr);
|
2014-11-14 13:50:10 +01:00
|
|
|
|
2019-08-23 09:52:12 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->owner_id);
|
2023-06-14 14:55:44 -04:00
|
|
|
WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, nullptr);
|
2017-06-08 10:14:53 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2010-10-05 11:55:54 +00:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 13:00:21 -05:00
|
|
|
static std::optional<std::string> rna_MaterialSlot_path(const PointerRNA *ptr)
|
2021-05-19 10:23:09 +02:00
|
|
|
{
|
|
|
|
|
int index = rna_MaterialSlot_index(ptr);
|
2024-01-31 13:00:21 -05:00
|
|
|
return fmt::format("material_slots[{}]", index);
|
2021-05-19 10:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_Object_material_slots_length(PointerRNA *ptr)
|
2013-10-01 04:49:47 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2025-05-02 15:08:29 +02:00
|
|
|
if (DEG_is_evaluated(ob)) {
|
2021-05-19 10:23:09 +02:00
|
|
|
return BKE_object_material_count_eval(ob);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return ob->totcol;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-10-01 04:49:47 +00:00
|
|
|
|
2021-05-19 10:23:09 +02:00
|
|
|
static void rna_Object_material_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
const int length = rna_Object_material_slots_length(ptr);
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
iter->parent = *ptr;
|
2021-05-19 10:23:09 +02:00
|
|
|
iter->internal.count.item = 0;
|
|
|
|
|
iter->internal.count.ptr = ptr->owner_id;
|
|
|
|
|
iter->valid = length > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_material_slots_next(CollectionPropertyIterator *iter)
|
|
|
|
|
{
|
|
|
|
|
const int length = rna_Object_material_slots_length(&iter->ptr);
|
|
|
|
|
iter->internal.count.item++;
|
|
|
|
|
iter->valid = iter->internal.count.item < length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
ID *id = static_cast<ID *>(iter->internal.count.ptr);
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
PointerRNA ptr = RNA_pointer_create_with_parent(
|
|
|
|
|
iter->parent,
|
2023-09-06 00:48:50 +02:00
|
|
|
&RNA_MaterialSlot,
|
|
|
|
|
/* Add offset, so that `ptr->data` is not null and unique across IDs. */
|
|
|
|
|
(void *)(iter->internal.count.item + uintptr_t(id)));
|
2021-05-19 10:23:09 +02:00
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_Object_material_slots_end(CollectionPropertyIterator * /*iter*/) {}
|
2013-10-01 04:49:47 +00:00
|
|
|
|
2019-02-11 10:32:11 +11:00
|
|
|
static PointerRNA rna_Object_display_get(PointerRNA *ptr)
|
|
|
|
|
{
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_ObjectDisplay, ptr->data);
|
2019-02-11 10:32:11 +11:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 13:00:21 -05:00
|
|
|
static std::optional<std::string> rna_ObjectDisplay_path(const PointerRNA * /*ptr*/)
|
2018-05-13 19:06:37 +02:00
|
|
|
{
|
2024-01-31 13:00:21 -05:00
|
|
|
return "display";
|
2018-05-13 19:06:37 +02:00
|
|
|
}
|
|
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2016-12-28 17:30:58 +01:00
|
|
|
ParticleSystem *psys = psys_get_current(ob);
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_ParticleSystem, psys);
|
2016-12-28 17:30:58 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-20 06:35:28 +00:00
|
|
|
static void rna_Object_active_shape_key_index_range(
|
2023-06-14 15:27:59 +02:00
|
|
|
PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
|
2009-07-02 03:32:57 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2012-09-19 10:12:07 +00:00
|
|
|
Key *key = BKE_key_from_object(ob);
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
*min = 0;
|
|
|
|
|
if (key) {
|
2014-11-16 13:57:58 +01:00
|
|
|
*max = BLI_listbase_count(&key->block) - 1;
|
2019-06-04 00:21:57 +10:00
|
|
|
if (*max < 0) {
|
2012-03-05 23:30:41 +00:00
|
|
|
*max = 0;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-06-23 06:13:21 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-03-05 23:30:41 +00:00
|
|
|
*max = 0;
|
2011-06-23 06:13:21 +00:00
|
|
|
}
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int rna_Object_active_shape_key_index_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2024-01-22 15:58:18 +01:00
|
|
|
return std::max<int>(ob->shapenr - 1, 0);
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-02 03:32:57 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
ob->shapenr = value + 1;
|
2009-07-02 03:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
static PointerRNA rna_Object_active_shape_key_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2012-09-19 10:12:07 +00:00
|
|
|
Key *key = BKE_key_from_object(ob);
|
2009-07-03 15:23:33 +00:00
|
|
|
KeyBlock *kb;
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (key == nullptr) {
|
2009-07-03 15:23:33 +00:00
|
|
|
return PointerRNA_NULL;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
kb = static_cast<KeyBlock *>(BLI_findlink(&key->block, ob->shapenr - 1));
|
2025-01-24 16:45:32 +01:00
|
|
|
PointerRNA keyptr = RNA_pointer_create_discrete(reinterpret_cast<ID *>(key), &RNA_ShapeKey, kb);
|
2009-07-03 15:23:33 +00:00
|
|
|
return keyptr;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-02 19:41:31 +00:00
|
|
|
static PointerRNA rna_Object_field_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-02 19:41:31 +00:00
|
|
|
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_FieldSettings, ob->pd);
|
2009-07-02 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_Object_collision_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2019-06-04 00:21:57 +10:00
|
|
|
if (ob->type != OB_MESH) {
|
2011-04-18 01:45:28 +00:00
|
|
|
return PointerRNA_NULL;
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-04-18 01:45:28 +00:00
|
|
|
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_CollisionSettings, ob->pd);
|
2009-07-02 19:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-11 19:58:30 +00:00
|
|
|
static PointerRNA rna_Object_active_constraint_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2014-04-11 11:47:07 +10:00
|
|
|
bConstraint *con = BKE_constraints_active_get(&ob->constraints);
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_Constraint, con);
|
2009-11-11 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
2019-05-20 18:06:09 +10:00
|
|
|
static void rna_Object_active_constraint_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2009-11-11 19:58:30 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
BKE_constraints_active_set(&ob->constraints, static_cast<bConstraint *>(value.data));
|
2009-11-11 19:58:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 12:27:47 +02:00
|
|
|
static bConstraint *rna_Object_constraints_new(Object *object, Main *bmain, int type)
|
2009-11-13 16:08:03 +00:00
|
|
|
{
|
2023-06-14 14:55:44 -04:00
|
|
|
bConstraint *new_con = BKE_constraint_add_for_object(object, nullptr, type);
|
2017-02-25 11:27:11 +01:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::constraint_tag_update(bmain, object, new_con);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
|
2017-02-25 11:27:11 +01:00
|
|
|
|
2024-05-28 11:08:26 +02:00
|
|
|
/* The Depsgraph needs to be updated to reflect the new relationship that was added. */
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
|
2017-02-25 11:27:11 +01:00
|
|
|
return new_con;
|
2009-11-13 16:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 12:27:47 +02:00
|
|
|
static void rna_Object_constraints_remove(Object *object,
|
|
|
|
|
Main *bmain,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
PointerRNA *con_ptr)
|
2009-11-13 16:08:03 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
|
2012-03-05 23:30:41 +00:00
|
|
|
if (BLI_findindex(&object->constraints, con) == -1) {
|
2012-05-12 11:01:29 +00:00
|
|
|
BKE_reportf(reports,
|
|
|
|
|
RPT_ERROR,
|
|
|
|
|
"Constraint '%s' not found in object '%s'",
|
|
|
|
|
con->name,
|
|
|
|
|
object->id.name + 2);
|
2010-09-07 05:47:34 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-25 12:11:15 +01:00
|
|
|
BKE_constraint_remove_ex(&object->constraints, object, con);
|
2025-02-18 12:31:20 +01:00
|
|
|
con_ptr->invalidate();
|
2012-11-02 09:41:26 +00:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::constraint_update(bmain, object);
|
|
|
|
|
blender::ed::object::constraint_active_set(object, nullptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
|
2009-11-13 16:08:03 +00:00
|
|
|
}
|
2009-11-16 11:11:16 +00:00
|
|
|
|
2018-05-31 12:27:47 +02:00
|
|
|
static void rna_Object_constraints_clear(Object *object, Main *bmain)
|
2011-11-23 16:12:11 +00:00
|
|
|
{
|
2014-04-11 11:47:07 +10:00
|
|
|
BKE_constraints_free(&object->constraints);
|
2011-11-23 16:12:11 +00:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::constraint_update(bmain, object);
|
|
|
|
|
blender::ed::object::constraint_active_set(object, nullptr);
|
2011-11-23 16:12:11 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, object);
|
2011-11-23 16:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
2019-09-04 22:09:57 +03:00
|
|
|
static void rna_Object_constraints_move(
|
|
|
|
|
Object *object, Main *bmain, ReportList *reports, int from, int to)
|
|
|
|
|
{
|
|
|
|
|
if (from == to) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!BLI_listbase_move_index(&object->constraints, from, to)) {
|
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "Could not move constraint from index '%d' to '%d'", from, to);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::constraint_tag_update(bmain, object, nullptr);
|
2019-09-04 22:09:57 +03:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT, object);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-24 22:10:43 +03:00
|
|
|
static bConstraint *rna_Object_constraints_copy(Object *object, Main *bmain, PointerRNA *con_ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
bConstraint *con = static_cast<bConstraint *>(con_ptr->data);
|
2020-06-24 22:10:43 +03:00
|
|
|
bConstraint *new_con = BKE_constraint_copy_for_object(object, con);
|
2021-11-19 11:48:25 +01:00
|
|
|
new_con->flag |= CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
|
2020-06-24 22:10:43 +03:00
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::constraint_tag_update(bmain, object, new_con);
|
2020-06-24 22:10:43 +03:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, object);
|
|
|
|
|
|
|
|
|
|
return new_con;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-01 12:21:00 +02:00
|
|
|
bool rna_Object_constraints_override_apply(Main *bmain,
|
2023-07-31 15:17:19 +02:00
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
2018-05-01 17:41:44 +02:00
|
|
|
{
|
2023-07-31 15:17:19 +02:00
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
2023-05-02 16:13:02 +02:00
|
|
|
BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER &&
|
2018-05-01 17:41:44 +02:00
|
|
|
"Unsupported RNA override operation on constraints collection");
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob_dst = reinterpret_cast<Object *>(ptr_dst->owner_id);
|
|
|
|
|
Object *ob_src = reinterpret_cast<Object *>(ptr_src->owner_id);
|
2018-05-02 11:35:24 +02:00
|
|
|
|
|
|
|
|
/* Remember that insertion operations are defined and stored in correct order, which means that
|
2019-08-17 00:54:22 +10:00
|
|
|
* even if we insert several items in a row, we always insert first one, then second one, etc.
|
|
|
|
|
* So we should always find 'anchor' constraint in both _src *and* _dst. */
|
2021-11-19 09:33:52 +01:00
|
|
|
const size_t name_offset = offsetof(bConstraint, name);
|
2023-06-14 15:27:59 +02:00
|
|
|
bConstraint *con_anchor = static_cast<bConstraint *>(
|
|
|
|
|
BLI_listbase_string_or_index_find(&ob_dst->constraints,
|
|
|
|
|
opop->subitem_reference_name,
|
|
|
|
|
name_offset,
|
|
|
|
|
opop->subitem_reference_index));
|
2023-06-14 14:55:44 -04:00
|
|
|
/* If `con_anchor` is nullptr, `con_src` will be inserted in first position. */
|
2021-11-19 09:33:52 +01:00
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bConstraint *con_src = static_cast<bConstraint *>(BLI_listbase_string_or_index_find(
|
|
|
|
|
&ob_src->constraints, opop->subitem_local_name, name_offset, opop->subitem_local_index));
|
2021-11-19 09:33:52 +01:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (con_src == nullptr) {
|
|
|
|
|
BLI_assert(con_src != nullptr);
|
2021-11-19 09:33:52 +01:00
|
|
|
return false;
|
2018-05-02 11:35:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bConstraint *con_dst = BKE_constraint_duplicate_ex(con_src, 0, true);
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
/* This handles nullptr anchor as expected by adding at head of list. */
|
2018-05-02 11:35:24 +02:00
|
|
|
BLI_insertlinkafter(&ob_dst->constraints, con_anchor, con_dst);
|
|
|
|
|
|
2019-04-22 02:48:05 +10:00
|
|
|
/* This should actually *not* be needed in typical cases.
|
|
|
|
|
* However, if overridden source was edited, we *may* have some new conflicting names. */
|
2018-05-02 11:35:24 +02:00
|
|
|
BKE_constraint_unique_name(con_dst, &ob_dst->constraints);
|
|
|
|
|
|
|
|
|
|
// printf("%s: We inserted a constraint...\n", __func__);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
|
2018-05-02 11:35:24 +02:00
|
|
|
return true;
|
2018-05-01 17:41:44 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
static ModifierData *rna_Object_modifier_new(
|
|
|
|
|
Object *object, bContext *C, ReportList *reports, const char *name, int type)
|
2009-11-28 13:33:56 +00:00
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
ModifierData *md = blender::ed::object::modifier_add(
|
2021-02-17 15:09:05 +01:00
|
|
|
reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
|
|
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_ADDED, object);
|
|
|
|
|
|
|
|
|
|
return md;
|
2009-11-28 13:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
2012-11-02 09:41:26 +00:00
|
|
|
static void rna_Object_modifier_remove(Object *object,
|
|
|
|
|
bContext *C,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
PointerRNA *md_ptr)
|
2009-11-28 13:33:56 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
ModifierData *md = static_cast<ModifierData *>(md_ptr->data);
|
2024-03-28 01:30:38 +01:00
|
|
|
if (blender::ed::object::modifier_remove(
|
|
|
|
|
reports, CTX_data_main(C), CTX_data_scene(C), object, md) == false)
|
2020-07-09 11:44:11 +02:00
|
|
|
{
|
2012-11-02 09:41:26 +00:00
|
|
|
/* error is already set */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-18 12:31:20 +01:00
|
|
|
md_ptr->invalidate();
|
2011-11-23 16:12:11 +00:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
|
2011-11-23 16:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_modifier_clear(Object *object, bContext *C)
|
|
|
|
|
{
|
2024-04-30 15:46:01 -04:00
|
|
|
blender::ed::object::modifiers_clear(CTX_data_main(C), CTX_data_scene(C), object);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
|
2009-11-28 13:33:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-01-27 15:50:52 +01:00
|
|
|
static void rna_Object_modifier_move(Object *object, ReportList *reports, int from, int to)
|
2023-01-10 18:25:58 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
ModifierData *md = static_cast<ModifierData *>(BLI_findlink(&object->modifiers, from));
|
2023-01-10 18:25:58 +02:00
|
|
|
|
|
|
|
|
if (!md) {
|
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "Invalid original modifier index '%d'", from);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::modifier_move_to_index(reports, RPT_ERROR, object, md, to, false);
|
2023-01-10 18:25:58 +02:00
|
|
|
}
|
|
|
|
|
|
2020-12-02 13:35:07 +01:00
|
|
|
static PointerRNA rna_Object_active_modifier_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2020-12-02 13:35:07 +01:00
|
|
|
ModifierData *md = BKE_object_active_modifier(ob);
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_Modifier, md);
|
2020-12-02 13:35:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_active_modifier_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
ModifierData *md = static_cast<ModifierData *>(value.data);
|
2020-12-02 13:35:07 +01:00
|
|
|
|
2021-07-05 10:46:00 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob);
|
|
|
|
|
|
2020-12-02 13:35:07 +01:00
|
|
|
if (RNA_pointer_is_null(&value)) {
|
2023-06-14 14:55:44 -04:00
|
|
|
BKE_object_modifier_set_active(ob, nullptr);
|
2020-12-02 13:35:07 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (BLI_findindex(&ob->modifiers, md) == -1) {
|
|
|
|
|
BKE_reportf(
|
|
|
|
|
reports, RPT_ERROR, "Modifier \"%s\" is not in the object's modifier list", md->name);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BKE_object_modifier_set_active(ob, md);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 19:59:39 +01:00
|
|
|
bool rna_Object_modifiers_override_apply(Main *bmain,
|
2023-07-31 15:17:19 +02:00
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
2018-05-02 18:13:15 +02:00
|
|
|
{
|
2023-07-31 15:17:19 +02:00
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
2023-05-02 16:13:02 +02:00
|
|
|
BLI_assert(opop->operation == LIBOVERRIDE_OP_INSERT_AFTER &&
|
2018-05-02 18:13:15 +02:00
|
|
|
"Unsupported RNA override operation on modifiers collection");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob_dst = reinterpret_cast<Object *>(ptr_dst->owner_id);
|
|
|
|
|
Object *ob_src = reinterpret_cast<Object *>(ptr_src->owner_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-02 18:13:15 +02:00
|
|
|
/* Remember that insertion operations are defined and stored in correct order, which means that
|
2019-08-17 00:54:22 +10:00
|
|
|
* even if we insert several items in a row, we always insert first one, then second one, etc.
|
2020-01-21 19:59:39 +01:00
|
|
|
* So we should always find 'anchor' modifier in both _src *and* _dst. */
|
2021-11-19 09:33:52 +01:00
|
|
|
const size_t name_offset = offsetof(ModifierData, name);
|
2023-06-14 15:27:59 +02:00
|
|
|
ModifierData *mod_anchor = static_cast<ModifierData *>(
|
|
|
|
|
BLI_listbase_string_or_index_find(&ob_dst->modifiers,
|
|
|
|
|
opop->subitem_reference_name,
|
|
|
|
|
name_offset,
|
|
|
|
|
opop->subitem_reference_index));
|
2023-06-14 14:55:44 -04:00
|
|
|
/* If `mod_anchor` is nullptr, `mod_src` will be inserted in first position. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
ModifierData *mod_src = static_cast<ModifierData *>(BLI_listbase_string_or_index_find(
|
|
|
|
|
&ob_src->modifiers, opop->subitem_local_name, name_offset, opop->subitem_local_index));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (mod_src == nullptr) {
|
|
|
|
|
BLI_assert(mod_src != nullptr);
|
2020-04-15 17:23:56 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
/* While it would be nicer to use lower-level BKE_modifier_new() here, this one is lacking
|
2020-01-21 19:59:39 +01:00
|
|
|
* special-cases handling (particles and other physics modifiers mostly), so using the ED version
|
|
|
|
|
* instead, to avoid duplicating code. */
|
2024-03-28 01:30:38 +01:00
|
|
|
ModifierData *mod_dst = blender::ed::object::modifier_add(
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr, bmain, nullptr, ob_dst, mod_src->name, mod_src->type);
|
2020-01-21 19:59:39 +01:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (mod_dst == nullptr) {
|
2022-05-23 12:11:09 +02:00
|
|
|
/* This can happen e.g. when a modifier type is tagged as `eModifierTypeFlag_Single`, and that
|
|
|
|
|
* modifier has somehow been added already by another code path (e.g.
|
|
|
|
|
* `rna_CollisionSettings_dependency_update` does add the `eModifierType_Collision` singleton
|
|
|
|
|
* modifier).
|
|
|
|
|
*
|
|
|
|
|
* Try to handle this by finding already existing one here. */
|
|
|
|
|
const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)mod_src->type);
|
|
|
|
|
if (mti->flags & eModifierTypeFlag_Single) {
|
|
|
|
|
mod_dst = BKE_modifiers_findby_type(ob_dst, (ModifierType)mod_src->type);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
if (mod_dst == nullptr) {
|
|
|
|
|
BLI_assert(mod_src != nullptr);
|
2022-05-23 12:11:09 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-25 20:09:20 +11:00
|
|
|
/* XXX Current handling of 'copy' from particle-system modifier is *very* bad (it keeps same psys
|
2020-01-21 19:59:39 +01:00
|
|
|
* pointer as source, then calling code copies psys of object separately and do some magic
|
2020-01-25 20:09:20 +11:00
|
|
|
* remapping of pointers...), unfortunately several pieces of code in Object editing area rely on
|
2020-01-21 19:59:39 +01:00
|
|
|
* this behavior. So for now, hacking around it to get it doing what we want it to do, as getting
|
|
|
|
|
* a proper behavior would be everything but trivial, and this whole particle thingy is
|
|
|
|
|
* end-of-life. */
|
|
|
|
|
ParticleSystem *psys_dst = (mod_dst->type == eModifierType_ParticleSystem) ?
|
2023-06-14 15:27:59 +02:00
|
|
|
(reinterpret_cast<ParticleSystemModifierData *>(mod_dst))->psys :
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr;
|
2024-02-07 14:21:38 +01:00
|
|
|
const int persistent_uid = mod_dst->persistent_uid;
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_copydata(mod_src, mod_dst);
|
2024-02-07 14:21:38 +01:00
|
|
|
mod_dst->persistent_uid = persistent_uid;
|
2020-01-21 19:59:39 +01:00
|
|
|
if (mod_dst->type == eModifierType_ParticleSystem) {
|
|
|
|
|
psys_dst->flag &= ~PSYS_DELETE;
|
2023-06-14 15:27:59 +02:00
|
|
|
(reinterpret_cast<ParticleSystemModifierData *>(mod_dst))->psys = psys_dst;
|
2020-01-21 19:59:39 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-21 19:59:39 +01:00
|
|
|
BLI_remlink(&ob_dst->modifiers, mod_dst);
|
2023-06-14 14:55:44 -04:00
|
|
|
/* This handles nullptr anchor as expected by adding at head of list. */
|
2018-05-02 18:13:15 +02:00
|
|
|
BLI_insertlinkafter(&ob_dst->modifiers, mod_anchor, mod_dst);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-21 19:59:39 +01:00
|
|
|
// printf("%s: We inserted a modifier '%s'...\n", __func__, mod_dst->name);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);
|
2018-05-02 18:13:15 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* shader fx */
|
|
|
|
|
static ShaderFxData *rna_Object_shaderfx_new(
|
|
|
|
|
Object *object, bContext *C, ReportList *reports, const char *name, int type)
|
|
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
return blender::ed::object::shaderfx_add(
|
|
|
|
|
reports, CTX_data_main(C), CTX_data_scene(C), object, name, type);
|
2018-07-31 10:22:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_shaderfx_remove(Object *object,
|
|
|
|
|
bContext *C,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
PointerRNA *gmd_ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
ShaderFxData *gmd = static_cast<ShaderFxData *>(gmd_ptr->data);
|
2024-03-28 01:30:38 +01:00
|
|
|
if (blender::ed::object::shaderfx_remove(reports, CTX_data_main(C), object, gmd) == false) {
|
2018-07-31 10:22:19 +02:00
|
|
|
/* error is already set */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-18 12:31:20 +01:00
|
|
|
gmd_ptr->invalidate();
|
2018-07-31 10:22:19 +02:00
|
|
|
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_shaderfx_clear(Object *object, bContext *C)
|
|
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::shaderfx_clear(CTX_data_main(C), object);
|
2018-07-31 10:22:19 +02:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER | NA_REMOVED, object);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-10 20:29:40 +00:00
|
|
|
static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
|
|
|
|
|
{
|
2023-11-27 16:14:49 +01:00
|
|
|
using namespace blender;
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-11-27 16:14:49 +01:00
|
|
|
if (const std::optional<Bounds<float3>> bounds = BKE_object_boundbox_eval_cached_get(ob)) {
|
2025-06-16 15:49:14 +02:00
|
|
|
*reinterpret_cast<std::array<float3, 8> *>(values) = blender::bounds::corners(*bounds);
|
2010-02-10 20:29:40 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2023-11-27 16:14:49 +01:00
|
|
|
copy_vn_fl(values, 8 * 3, 0.0f);
|
2010-02-10 20:29:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
static bool check_object_vgroup_support_and_warn(const Object *ob,
|
|
|
|
|
const char *op_name,
|
|
|
|
|
ReportList *reports)
|
|
|
|
|
{
|
|
|
|
|
if (!BKE_object_supports_vertex_groups(ob)) {
|
|
|
|
|
const char *ob_type_name = "Unknown";
|
|
|
|
|
RNA_enum_name_from_value(rna_enum_object_type_items, ob->type, &ob_type_name);
|
|
|
|
|
BKE_reportf(reports, RPT_ERROR, "%s is not supported for '%s' objects", op_name, ob_type_name);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-14 18:25:54 +10:00
|
|
|
static bDeformGroup *rna_Object_vgroup_new(Object *ob,
|
|
|
|
|
Main *bmain,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
2021-07-16 12:23:55 -04:00
|
|
|
if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.new()", reports)) {
|
2023-06-14 14:55:44 -04:00
|
|
|
return nullptr;
|
2020-09-14 18:25:54 +10:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
bDeformGroup *defgroup = BKE_object_defgroup_add_name(ob, name);
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2019-04-24 16:24:53 +03:00
|
|
|
DEG_relations_tag_update(bmain);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
|
2011-01-07 09:50:23 +00:00
|
|
|
|
|
|
|
|
return defgroup;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-24 16:24:53 +03:00
|
|
|
static void rna_Object_vgroup_remove(Object *ob,
|
|
|
|
|
Main *bmain,
|
|
|
|
|
ReportList *reports,
|
|
|
|
|
PointerRNA *defgroup_ptr)
|
2010-09-07 05:47:34 +00:00
|
|
|
{
|
2021-07-16 12:23:55 -04:00
|
|
|
if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.remove()", reports)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bDeformGroup *defgroup = static_cast<bDeformGroup *>(defgroup_ptr->data);
|
2021-07-13 12:10:34 -04:00
|
|
|
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);
|
|
|
|
|
|
|
|
|
|
if (BLI_findindex(defbase, defgroup) == -1) {
|
2012-11-02 09:41:26 +00:00
|
|
|
BKE_reportf(reports,
|
|
|
|
|
RPT_ERROR,
|
|
|
|
|
"DeformGroup '%s' not in object '%s'",
|
|
|
|
|
defgroup->name,
|
|
|
|
|
ob->id.name + 2);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
BKE_object_defgroup_remove(ob, defgroup);
|
2025-02-18 12:31:20 +01:00
|
|
|
defgroup_ptr->invalidate();
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2019-04-24 16:24:53 +03:00
|
|
|
DEG_relations_tag_update(bmain);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
|
2011-01-07 09:50:23 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-16 12:23:55 -04:00
|
|
|
static void rna_Object_vgroup_clear(Object *ob, Main *bmain, ReportList *reports)
|
2011-11-23 16:12:11 +00:00
|
|
|
{
|
2021-07-16 12:23:55 -04:00
|
|
|
if (!check_object_vgroup_support_and_warn(ob, "VertexGroups.clear()", reports)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-18 23:52:17 +01:00
|
|
|
BKE_object_defgroup_remove_all(ob);
|
2011-11-23 16:12:11 +00:00
|
|
|
|
2019-04-24 16:24:53 +03:00
|
|
|
DEG_relations_tag_update(bmain);
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
|
2011-11-23 16:12:11 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-25 09:55:13 +00:00
|
|
|
static void rna_VertexGroup_vertex_add(ID *id,
|
|
|
|
|
bDeformGroup *def,
|
|
|
|
|
ReportList *reports,
|
2023-08-01 16:46:17 +10:00
|
|
|
const int *index,
|
|
|
|
|
int index_num,
|
2011-09-25 09:55:13 +00:00
|
|
|
float weight,
|
|
|
|
|
int assignmode)
|
2011-01-07 09:50:23 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(id);
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2014-11-17 20:33:25 +01:00
|
|
|
if (BKE_object_is_in_editmode_vgroup(ob)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_report(
|
|
|
|
|
reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode");
|
2011-01-07 09:50:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-01 16:46:17 +10:00
|
|
|
while (index_num--) {
|
2021-06-23 12:05:40 +10:00
|
|
|
/* XXX: not efficient calling within loop. */
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::vgroup_vert_add(ob, def, *index++, weight, assignmode);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2019-03-09 11:45:31 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2023-06-14 15:27:59 +02:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, static_cast<ID *>(ob->data));
|
2011-01-07 09:50:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_VertexGroup_vertex_remove(
|
2023-08-01 16:46:17 +10:00
|
|
|
ID *id, bDeformGroup *dg, ReportList *reports, const int *index, int index_num)
|
2011-01-07 09:50:23 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(id);
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2014-11-17 20:33:25 +01:00
|
|
|
if (BKE_object_is_in_editmode_vgroup(ob)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_report(
|
|
|
|
|
reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode");
|
2011-01-07 09:50:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-01 16:46:17 +10:00
|
|
|
while (index_num--) {
|
2024-03-28 01:30:38 +01:00
|
|
|
blender::ed::object::vgroup_vert_remove(ob, dg, *index++);
|
2019-06-04 00:21:57 +10:00
|
|
|
}
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2019-03-09 11:45:31 +01:00
|
|
|
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
2023-06-14 15:27:59 +02:00
|
|
|
WM_main_add_notifier(NC_GEOM | ND_DATA, static_cast<ID *>(ob->data));
|
2011-01-07 09:50:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *reports, int index)
|
|
|
|
|
{
|
2024-03-28 01:30:38 +01:00
|
|
|
float weight = blender::ed::object::vgroup_vert_weight(
|
|
|
|
|
reinterpret_cast<Object *>(id), dg, index);
|
2011-01-07 09:50:23 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
if (weight < 0) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_report(reports, RPT_ERROR, "Vertex not in group");
|
2011-01-07 09:50:23 +00:00
|
|
|
}
|
2012-03-18 09:27:36 +00:00
|
|
|
return weight;
|
2010-09-07 05:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
2010-08-03 06:51:36 +00:00
|
|
|
/* generic poll functions */
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Lattice_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2010-08-03 06:51:36 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_LATTICE;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Curve_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2010-08-03 06:51:36 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_CURVES_LEGACY;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Armature_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2010-08-03 06:51:36 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_ARMATURE;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Mesh_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2010-08-03 06:51:36 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_MESH;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Camera_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2010-08-03 06:51:36 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_CAMERA;
|
2010-08-03 06:51:36 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
bool rna_Light_object_poll(PointerRNA * /*ptr*/, PointerRNA value)
|
2013-11-25 20:58:23 +09:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return (reinterpret_cast<Object *>(value.owner_id))->type == OB_LAMP;
|
2013-11-25 20:58:23 +09:00
|
|
|
}
|
|
|
|
|
|
2022-08-26 14:37:16 +10:00
|
|
|
bool rna_Object_use_dynamic_topology_sculpting_get(PointerRNA *ptr)
|
2012-12-30 18:27:33 +00:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
return BKE_object_sculpt_use_dyntopo(reinterpret_cast<Object *>(ptr->owner_id));
|
2012-12-30 18:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_object_lineart_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
|
2021-03-16 19:35:53 +01:00
|
|
|
{
|
|
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->owner_id);
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-31 13:00:21 -05:00
|
|
|
static std::optional<std::string> rna_ObjectLineArt_path(const PointerRNA * /*ptr*/)
|
2022-11-25 23:15:05 +08:00
|
|
|
{
|
2024-01-31 13:00:21 -05:00
|
|
|
return "lineart";
|
2022-11-25 23:15:05 +08:00
|
|
|
}
|
|
|
|
|
|
2021-04-02 14:44:26 +02:00
|
|
|
static bool mesh_symmetry_get_common(PointerRNA *ptr, const eMeshSymmetryType sym)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
const Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-04-02 14:44:26 +02:00
|
|
|
if (ob->type != OB_MESH) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
2021-04-02 14:44:26 +02:00
|
|
|
return mesh->symmetry & sym;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool rna_Object_mesh_symmetry_x_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return mesh_symmetry_get_common(ptr, ME_SYMMETRY_X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool rna_Object_mesh_symmetry_y_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool rna_Object_mesh_symmetry_z_get(PointerRNA *ptr)
|
|
|
|
|
{
|
|
|
|
|
return mesh_symmetry_get_common(ptr, ME_SYMMETRY_Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void mesh_symmetry_set_common(PointerRNA *ptr,
|
|
|
|
|
const bool value,
|
|
|
|
|
const eMeshSymmetryType sym)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-04-02 14:44:26 +02:00
|
|
|
if (ob->type != OB_MESH) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
2021-04-02 14:44:26 +02:00
|
|
|
if (value) {
|
|
|
|
|
mesh->symmetry |= sym;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
mesh->symmetry &= ~sym;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_mesh_symmetry_x_set(PointerRNA *ptr, bool value)
|
|
|
|
|
{
|
|
|
|
|
mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_mesh_symmetry_y_set(PointerRNA *ptr, bool value)
|
|
|
|
|
{
|
|
|
|
|
mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_Object_mesh_symmetry_z_set(PointerRNA *ptr, bool value)
|
|
|
|
|
{
|
|
|
|
|
mesh_symmetry_set_common(ptr, value, ME_SYMMETRY_Z);
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-27 16:12:58 +01:00
|
|
|
static int rna_Object_mesh_symmetry_yz_editable(const PointerRNA *ptr, const char ** /*r_info*/)
|
2021-04-02 14:44:26 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
const Object *ob = reinterpret_cast<Object *>(ptr->owner_id);
|
2021-04-02 14:44:26 +02:00
|
|
|
if (ob->type != OB_MESH) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
const Mesh *mesh = static_cast<Mesh *>(ob->data);
|
2021-04-02 14:44:26 +02:00
|
|
|
if (ob->mode == OB_MODE_WEIGHT_PAINT && mesh->editflag & ME_EDIT_MIRROR_VERTEX_GROUPS) {
|
2023-09-03 21:35:03 +10:00
|
|
|
/* Only X symmetry is available in weight-paint mode. */
|
2021-04-02 14:44:26 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return PROP_EDITABLE;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-02 00:11:11 +02:00
|
|
|
void rna_Object_lightgroup_get(PointerRNA *ptr, char *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
const LightgroupMembership *lgm = (reinterpret_cast<Object *>(ptr->owner_id))->lightgroup;
|
2023-05-05 13:09:16 +10:00
|
|
|
char value_buf[sizeof(lgm->name)];
|
|
|
|
|
int len = BKE_lightgroup_membership_get(lgm, value_buf);
|
|
|
|
|
memcpy(value, value_buf, len + 1);
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rna_Object_lightgroup_length(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
const LightgroupMembership *lgm = (reinterpret_cast<Object *>(ptr->owner_id))->lightgroup;
|
2023-05-05 13:09:16 +10:00
|
|
|
return BKE_lightgroup_membership_length(lgm);
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rna_Object_lightgroup_set(PointerRNA *ptr, const char *value)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
BKE_lightgroup_membership_set(&(reinterpret_cast<Object *>(ptr->owner_id))->lightgroup, value);
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
static PointerRNA rna_Object_light_linking_get(PointerRNA *ptr)
|
|
|
|
|
{
|
Core: Add info about chain of ancestors (owner data) of a PointerRNA.
The general idea is to store an array of (type, data) pointers of all
PointerRNA ancestors of the current one.
This will help solving cases in our code where the owner (or sometimes
even the owner of the owner) of a random PointerRNA needs to be
accessed. Current solution mainly relies on linear search from the owner
ID, which is sub-optimal at best, and may not even be possible in case a
same data is shared between different owners.
This lead to refactoring quite a bit of existing PointerRNA creation code.
At a high level (i.e. expected usages outside of RNA internals):
* Add `RNA_pointer_create_with_parent` and
`RNA_pointer_create_id_subdata` to create RNA pointers with
ancestors info.
* `RNA_id_pointer_create` and `RNA_main_pointer_create` remain
unchanged, as they should never have ancestors currently.
* Add `RNA_pointer_create_from_ancestor` to re-create a RNA pointer
from the nth ancestor of another PointerRNA.
* Add basic python API to access this new ancestors data.
* Update internal RNA/bpy code to handle ancestors generation in most
common generic cases.
- The most verbose change here is for collection code, as the owner of the
collection property is now passed around, to allow collection items to get
a valid ancestors chain.
Internally:
* `PointerRNA` now has an array of `AncestorPointerRNA` data to store
the ancestors.
* `PointerRNA` now has constructors that take care of setting its data for
most usual cases, including handling of the ancestor array data.
* Pointer type refining has been fully factorized into a small utils,
`rna_pointer_refine`, that is now used from all code doing that operation.
* `rna_pointer_inherit_refine` has been replaced by
`rna_pointer_create_with_ancestors` as the core function taking care of
creating pointers with valid ancestors info.
- Its usage outside of `rna_access` has been essentially reduced to custom
collection lookup callbacks.
Implements #122431.
--------------
Some notes:
* The goal of this commit is _not_ to fully cover all cases creating
PointerRNA that should also store the ancestors' chain info. It only
tackles the most generic code paths (in bpyrna and RNA itself mainly).
The remaining 'missing cases' can be tackle later, as needs be.
* Performances seem to be only marginally affected currently.
* Currently `AncestorPointerRNA` only stores PointerRNA-like data.
This will help `StructPathFunc` callbacks to more efficiently generate
an RNA paths when calling e.g. `RNA_path_from_ID_to_property`, but will
not be enough info to build these paths without these callbacks. And some
cases may still remain fuzzy. We'd have to add thinks like a `PropertyRNA`
pointer, and for RNA collection ones, an index and string identifier, to store
a complete unambiguous 'RNA path' info. This is probably not needed, nor
worth the extra processing and memory footprint, for now.
Pull Request: https://projects.blender.org/blender/blender/pulls/122427
2025-02-05 15:45:04 +01:00
|
|
|
return RNA_pointer_create_with_parent(*ptr, &RNA_ObjectLightLinking, ptr->data);
|
2023-05-24 13:36:13 +02:00
|
|
|
}
|
|
|
|
|
|
2024-01-31 13:00:21 -05:00
|
|
|
static std::optional<std::string> rna_ObjectLightLinking_path(const PointerRNA * /*ptr*/)
|
2023-05-24 13:36:13 +02:00
|
|
|
{
|
2024-01-31 13:00:21 -05:00
|
|
|
return "light_linking";
|
2023-05-24 13:36:13 +02:00
|
|
|
}
|
|
|
|
|
|
2025-10-01 18:11:19 +02:00
|
|
|
bool rna_Object_light_linking_override_apply(Main *bmain,
|
|
|
|
|
RNAPropertyOverrideApplyContext &rnaapply_ctx)
|
|
|
|
|
{
|
|
|
|
|
/* NOTE: Here:
|
|
|
|
|
* - `dst` is the new, being updated liboverride data, which is a clean copy from the linked
|
|
|
|
|
* reference data.
|
|
|
|
|
* - `src` is the old, stored liboverride data, which is the source to copy overridden data
|
|
|
|
|
* from.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
|
|
|
|
|
PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
|
|
|
|
|
PointerRNA *ptr_storage = &rnaapply_ctx.ptr_storage;
|
|
|
|
|
const int len_dst = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_src = rnaapply_ctx.len_src;
|
|
|
|
|
const int len_storage = rnaapply_ctx.len_storage;
|
|
|
|
|
IDOverrideLibraryPropertyOperation *opop = rnaapply_ctx.liboverride_operation;
|
|
|
|
|
|
|
|
|
|
BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
|
|
|
|
|
BLI_assert_msg(opop->operation == LIBOVERRIDE_OP_REPLACE,
|
|
|
|
|
"Unsupported RNA override operation on object light linking pointer");
|
|
|
|
|
UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
|
|
|
|
|
|
|
|
|
|
/* LightLinking is a special case, since you cannot edit/replace it, it's either existent or not.
|
|
|
|
|
* Further more, when a lightlinking is added to the linked reference later on, the one created
|
|
|
|
|
* for the liboverride needs to be 'merged', such that its overridable data is kept. */
|
|
|
|
|
Object *ob_dst = blender::id_cast<Object *>(ptr_dst->owner_id);
|
|
|
|
|
Object *ob_src = blender::id_cast<Object *>(ptr_src->owner_id);
|
|
|
|
|
|
|
|
|
|
if (ob_dst->light_linking == nullptr && ob_src->light_linking == nullptr) {
|
|
|
|
|
/* Nothing to do. */
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ob_dst->light_linking == nullptr && ob_src->light_linking != nullptr) {
|
|
|
|
|
/* Copy light linking data from previous liboverride data into final liboverride one. */
|
|
|
|
|
BKE_light_linking_copy(ob_dst, ob_src, 0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else if (ob_dst->light_linking != nullptr && ob_src->light_linking == nullptr) {
|
|
|
|
|
/* Override has cleared/removed light linking data from its reference. */
|
|
|
|
|
BKE_light_linking_delete(ob_dst, 0);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_assert(ob_dst->light_linking != nullptr && ob_src->light_linking != nullptr);
|
|
|
|
|
/* Override had to create a light linking data, but now its reference also has one, need to
|
|
|
|
|
* merge them by keeping the overridable data from the liboverride, while using the light
|
|
|
|
|
* linking of the reference.
|
|
|
|
|
*
|
|
|
|
|
* Note that this case will not be encountered when the linked reference data already had
|
|
|
|
|
* light linking data, since there will be no operation for the light linking pointer itself
|
|
|
|
|
* then, only potentially for its internal overridable data (collections...). */
|
|
|
|
|
|
|
|
|
|
/* For these collections, only replace linked data with previously defined liboverride data if
|
|
|
|
|
* the latter is non-null. Otherwise, assume that the previously defined liboverride data
|
|
|
|
|
* property was 'unset', and can be replaced by the linked reference value. */
|
|
|
|
|
if (ob_src->light_linking->receiver_collection != nullptr) {
|
|
|
|
|
id_us_min(blender::id_cast<ID *>(ob_dst->light_linking->receiver_collection));
|
|
|
|
|
ob_dst->light_linking->receiver_collection = ob_src->light_linking->receiver_collection;
|
|
|
|
|
id_us_plus(blender::id_cast<ID *>(ob_dst->light_linking->receiver_collection));
|
|
|
|
|
}
|
|
|
|
|
if (ob_src->light_linking->blocker_collection != nullptr) {
|
|
|
|
|
id_us_min(blender::id_cast<ID *>(ob_dst->light_linking->blocker_collection));
|
|
|
|
|
ob_dst->light_linking->blocker_collection = ob_src->light_linking->blocker_collection;
|
|
|
|
|
id_us_plus(blender::id_cast<ID *>(ob_dst->light_linking->blocker_collection));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Note: LightLinking runtime data is currently set by depsgraph evaluation, so no need to
|
|
|
|
|
* handle them here. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEG_id_tag_update(&ob_dst->id, ID_RECALC_SHADING);
|
|
|
|
|
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob_dst->id);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
static PointerRNA rna_LightLinking_receiver_collection_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *object = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-09-06 00:48:50 +02:00
|
|
|
PointerRNA collection_ptr = RNA_id_pointer_create(
|
|
|
|
|
reinterpret_cast<ID *>(BKE_light_linking_collection_get(object, LIGHT_LINKING_RECEIVER)));
|
2023-05-24 13:36:13 +02:00
|
|
|
return collection_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_LightLinking_receiver_collection_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2023-05-24 13:36:13 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *object = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
Collection *new_collection = static_cast<Collection *>(value.data);
|
2023-05-24 13:36:13 +02:00
|
|
|
|
|
|
|
|
BKE_light_linking_collection_assign_only(object, new_collection, LIGHT_LINKING_RECEIVER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA rna_LightLinking_blocker_collection_get(PointerRNA *ptr)
|
|
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *object = reinterpret_cast<Object *>(ptr->owner_id);
|
2023-09-06 00:48:50 +02:00
|
|
|
PointerRNA collection_ptr = RNA_id_pointer_create(
|
|
|
|
|
reinterpret_cast<ID *>(BKE_light_linking_collection_get(object, LIGHT_LINKING_BLOCKER)));
|
2023-05-24 13:36:13 +02:00
|
|
|
return collection_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void rna_LightLinking_blocker_collection_set(PointerRNA *ptr,
|
|
|
|
|
PointerRNA value,
|
2023-07-01 16:38:46 +02:00
|
|
|
ReportList * /*reports*/)
|
2023-05-24 13:36:13 +02:00
|
|
|
{
|
2023-06-14 15:27:59 +02:00
|
|
|
Object *object = reinterpret_cast<Object *>(ptr->owner_id);
|
|
|
|
|
Collection *new_collection = static_cast<Collection *>(value.data);
|
2023-05-24 13:36:13 +02:00
|
|
|
|
|
|
|
|
BKE_light_linking_collection_assign_only(object, new_collection, LIGHT_LINKING_BLOCKER);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-14 15:27:59 +02:00
|
|
|
static void rna_LightLinking_collection_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
2023-05-24 13:36:13 +02:00
|
|
|
{
|
|
|
|
|
DEG_id_tag_update(ptr->owner_id, ID_RECALC_SHADING);
|
|
|
|
|
|
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
|
WM_main_add_notifier(NC_OBJECT | ND_DRAW, ptr->owner_id);
|
|
|
|
|
}
|
|
|
|
|
|
2008-10-31 23:50:02 +00:00
|
|
|
#else
|
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
static void rna_def_vertex_group(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2011-01-07 09:50:23 +00:00
|
|
|
FunctionRNA *func;
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
PropertyRNA *parm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem assign_mode_items[] = {
|
2011-01-07 09:50:23 +00:00
|
|
|
{WEIGHT_REPLACE, "REPLACE", 0, "Replace", "Replace"},
|
|
|
|
|
{WEIGHT_ADD, "ADD", 0, "Add", "Add"},
|
|
|
|
|
{WEIGHT_SUBTRACT, "SUBTRACT", 0, "Subtract", "Subtract"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2011-01-07 09:50:23 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "VertexGroup", nullptr);
|
2009-01-01 20:44:40 +00:00
|
|
|
RNA_def_struct_sdna(srna, "bDeformGroup");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(
|
|
|
|
|
srna, "Vertex Group", "Group of vertices, used for armature deform and other purposes");
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_GROUP_VERTEX);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Vertex group name");
|
2009-01-01 20:44:40 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_VertexGroup_name_set");
|
2023-02-12 14:37:16 +11:00
|
|
|
/* update data because modifiers may use #24761. */
|
2019-04-24 16:24:53 +03:00
|
|
|
RNA_def_property_update(
|
|
|
|
|
prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data_dependency");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_weight", PROP_BOOLEAN, PROP_NONE);
|
2011-05-27 19:13:54 +00:00
|
|
|
RNA_def_property_ui_text(prop, "", "Maintain the relative weights for the group");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "flag", 0);
|
2023-02-12 14:37:16 +11:00
|
|
|
/* update data because modifiers may use #24761. */
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED);
|
2009-03-23 13:24:48 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_VertexGroup_index_get", nullptr, nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Index", "Index number of the vertex group");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "add", "rna_VertexGroup_vertex_add");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Add vertices to the group");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: see how array size of 0 works, this shouldn't be used. */
|
2023-06-14 14:55:44 -04:00
|
|
|
parm = RNA_def_int_array(func, "index", 1, nullptr, 0, 0, "", "List of indices", 0, 0);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
|
|
|
|
|
parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
parm = RNA_def_enum(func, "type", assign_mode_items, 0, "", "Vertex assign mode");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_VertexGroup_vertex_remove");
|
2021-02-19 20:54:06 +11:00
|
|
|
RNA_def_function_ui_description(func, "Remove vertices from the group");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: see how array size of 0 works, this shouldn't be used. */
|
2023-06-14 14:55:44 -04:00
|
|
|
parm = RNA_def_int_array(func, "index", 1, nullptr, 0, 0, "", "List of indices", 0, 0);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "weight", "rna_VertexGroup_weight");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Get a vertex weight from the group");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
parm = RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "The index of the vertex", 0, INT_MAX);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
parm = RNA_def_float(func, "weight", 0, 0.0f, 1.0f, "", "Vertex weight", 0.0f, 1.0f);
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2009-01-01 20:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:22:43 +00:00
|
|
|
static void rna_def_material_slot(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem link_items[] = {
|
2024-09-12 19:23:09 +02:00
|
|
|
{1, "OBJECT", ICON_OBJECT_DATAMODE, "Object", ""},
|
|
|
|
|
{0, "DATA", ICON_MESH_DATA, "Data", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-06-03 23:22:43 +00:00
|
|
|
/* NOTE: there is no MaterialSlot equivalent in DNA, so the internal
|
|
|
|
|
* pointer data points to ob->mat + index, and we manually implement
|
|
|
|
|
* get/set for the properties. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "MaterialSlot", nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Material Slot", "Material slot in an object");
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_MATERIAL_DATA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(true);
|
|
|
|
|
|
2018-06-05 12:07:20 +02:00
|
|
|
/* WARNING! Order is crucial for override to work properly here... :/
|
2019-04-22 02:48:05 +10:00
|
|
|
* 'link' must come before material pointer,
|
|
|
|
|
* since it defines where (in object or obdata) that one is set! */
|
2018-06-05 12:07:20 +02:00
|
|
|
prop = RNA_def_property(srna, "link", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(prop, link_items);
|
|
|
|
|
RNA_def_property_enum_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_MaterialSlot_link_get", "rna_MaterialSlot_link_set", nullptr);
|
2018-06-05 12:07:20 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Link", "Link material to object or the object's data");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Material");
|
2025-08-01 14:01:24 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
|
2018-06-11 19:28:12 +02:00
|
|
|
RNA_def_property_editable_func(prop, "rna_MaterialSlot_material_editable");
|
2018-07-31 10:22:19 +02:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_MaterialSlot_material_get",
|
|
|
|
|
"rna_MaterialSlot_material_set",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
2018-07-31 10:22:19 +02:00
|
|
|
"rna_MaterialSlot_material_poll");
|
2015-10-24 02:44:43 +11:00
|
|
|
RNA_def_property_ui_text(prop, "Material", "Material data-block used by this material slot");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-03 15:28:48 -08:00
|
|
|
prop = RNA_def_property(srna, "slot_index", PROP_INT, PROP_NONE);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_funcs(prop, "rna_MaterialSlot_index_get", nullptr, nullptr);
|
2022-03-03 15:28:48 -08:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_property_string_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_MaterialSlot_name_get", "rna_MaterialSlot_name_length", nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Name", "Material slot name");
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_struct_name_property(srna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(false);
|
|
|
|
|
|
2013-10-01 04:49:47 +00:00
|
|
|
RNA_def_struct_path_func(srna, "rna_MaterialSlot_path");
|
2009-06-03 23:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
2009-11-13 16:08:03 +00:00
|
|
|
static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2009-11-14 08:50:02 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-13 16:08:03 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-16 11:11:16 +00:00
|
|
|
RNA_def_property_srna(cprop, "ObjectConstraints");
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectConstraints", nullptr);
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Object Constraints", "Collection of object constraints");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-13 16:08:03 +00:00
|
|
|
/* Collection active property */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
2009-11-13 18:47:20 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Constraint");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_Object_active_constraint_get",
|
|
|
|
|
"rna_Object_active_constraint_set",
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2009-11-13 18:47:20 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Constraint", "Active Object constraint");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-13 16:08:03 +00:00
|
|
|
/* Constraint collection */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "rna_Object_constraints_new");
|
2009-11-16 11:11:16 +00:00
|
|
|
RNA_def_function_ui_description(func, "Add a new constraint to this object");
|
2018-05-31 12:27:47 +02:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN);
|
2009-11-13 16:08:03 +00:00
|
|
|
/* object to add */
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(
|
|
|
|
|
func, "type", rna_enum_constraint_type_items, 1, "", "Constraint type to add");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2009-11-13 16:08:03 +00:00
|
|
|
/* return type */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "New constraint");
|
2009-11-13 16:08:03 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_Object_constraints_remove");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Remove a constraint from this object");
|
2018-05-31 12:27:47 +02:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
2010-09-07 05:47:34 +00:00
|
|
|
/* constraint to remove */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "rna_Object_constraints_clear");
|
2018-05-31 12:27:47 +02:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN);
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Remove all constraint from this object");
|
2019-09-04 22:09:57 +03:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "move", "rna_Object_constraints_move");
|
|
|
|
|
RNA_def_function_ui_description(func, "Move a constraint to a different position");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
|
|
|
|
parm = RNA_def_int(
|
|
|
|
|
func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2019-09-04 22:09:57 +03:00
|
|
|
parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2020-06-24 22:10:43 +03:00
|
|
|
|
|
|
|
|
func = RNA_def_function(srna, "copy", "rna_Object_constraints_copy");
|
|
|
|
|
RNA_def_function_ui_description(func, "Add a new constraint that is a copy of the given one");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN);
|
|
|
|
|
/* constraint to copy */
|
|
|
|
|
parm = RNA_def_pointer(func,
|
|
|
|
|
"constraint",
|
|
|
|
|
"Constraint",
|
|
|
|
|
"",
|
|
|
|
|
"Constraint to copy - may belong to a different object");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2020-06-24 22:10:43 +03:00
|
|
|
/* return type */
|
|
|
|
|
parm = RNA_def_pointer(func, "new_constraint", "Constraint", "", "New constraint");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2009-11-13 16:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
/* object.modifiers */
|
2009-11-28 13:33:56 +00:00
|
|
|
static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-28 13:33:56 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
2020-12-02 13:35:07 +01:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-28 13:33:56 +00:00
|
|
|
RNA_def_property_srna(cprop, "ObjectModifiers");
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectModifiers", nullptr);
|
2009-11-28 13:33:56 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_struct_ui_text(srna, "Object Modifiers", "Collection of object modifiers");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-28 13:33:56 +00:00
|
|
|
# if 0
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
2009-11-28 13:33:56 +00:00
|
|
|
RNA_def_property_struct_type(prop, "EditBone");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "act_edbone");
|
2009-11-28 13:33:56 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active EditBone", "Armatures active edit bone");
|
2022-04-13 13:46:22 +10:00
|
|
|
// RNA_def_property_update(prop, 0, "rna_Armature_act_editbone_update");
|
2023-08-09 10:47:43 +10:00
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, nullptr, "rna_Armature_act_edit_bone_set", nullptr, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* TODO: redraw. */
|
2022-04-13 13:46:22 +10:00
|
|
|
// RNA_def_property_collection_active(prop, prop_act);
|
2009-11-28 13:33:56 +00:00
|
|
|
# endif
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-23 21:47:11 +00:00
|
|
|
/* add modifier */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "new", "rna_Object_modifier_new");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Add a new modifier");
|
2012-08-20 10:15:32 +00:00
|
|
|
parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2009-11-28 13:33:56 +00:00
|
|
|
/* modifier to add */
|
2015-11-23 13:49:52 +11:00
|
|
|
parm = RNA_def_enum(
|
|
|
|
|
func, "type", rna_enum_object_modifier_type_items, 1, "", "Modifier type to add");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2009-11-28 13:33:56 +00:00
|
|
|
/* return type */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Newly created modifier");
|
2009-11-28 13:33:56 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-23 21:47:11 +00:00
|
|
|
/* remove modifier */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_Object_modifier_remove");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Remove an existing modifier from the object");
|
2012-07-23 21:47:11 +00:00
|
|
|
/* modifier to remove */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-23 16:12:11 +00:00
|
|
|
/* clear all modifiers */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "rna_Object_modifier_clear");
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
|
|
|
|
RNA_def_function_ui_description(func, "Remove all modifiers from the object");
|
2020-12-02 13:35:07 +01:00
|
|
|
|
2023-01-10 18:25:58 +02:00
|
|
|
/* move a modifier */
|
|
|
|
|
func = RNA_def_function(srna, "move", "rna_Object_modifier_move");
|
|
|
|
|
RNA_def_function_ui_description(func, "Move a modifier to a different position");
|
2023-01-27 15:50:52 +01:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_REPORTS);
|
2023-01-10 18:25:58 +02:00
|
|
|
parm = RNA_def_int(
|
|
|
|
|
func, "from_index", -1, INT_MIN, INT_MAX, "From Index", "Index to move", 0, 10000);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2023-01-10 18:25:58 +02:00
|
|
|
parm = RNA_def_int(func, "to_index", -1, INT_MIN, INT_MAX, "To Index", "Target index", 0, 10000);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2023-01-10 18:25:58 +02:00
|
|
|
|
2020-12-02 13:35:07 +01:00
|
|
|
/* Active modifier. */
|
|
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "Modifier");
|
|
|
|
|
RNA_def_property_pointer_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_Object_active_modifier_get", "rna_Object_active_modifier_set", nullptr, nullptr);
|
2020-12-02 13:35:07 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
|
|
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Active Modifier", "The active modifier in the list");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, nullptr);
|
2010-09-07 05:47:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* object.shaderfxs */
|
|
|
|
|
static void rna_def_object_shaderfxs(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
RNA_def_property_srna(cprop, "ObjectShaderFx");
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectShaderFx", nullptr);
|
2018-07-31 10:22:19 +02:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Object Shader Effects", "Collection of object effects");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* add shader_fx */
|
|
|
|
|
func = RNA_def_function(srna, "new", "rna_Object_shaderfx_new");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
|
|
|
|
RNA_def_function_ui_description(func, "Add a new shader fx");
|
|
|
|
|
parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the effect");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2018-07-31 10:22:19 +02:00
|
|
|
/* shader to add */
|
|
|
|
|
parm = RNA_def_enum(
|
|
|
|
|
func, "type", rna_enum_object_shaderfx_type_items, 1, "", "Effect type to add");
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_flags(parm, PropertyFlag(0), PARM_REQUIRED);
|
2018-07-31 10:22:19 +02:00
|
|
|
/* return type */
|
|
|
|
|
parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Newly created effect");
|
|
|
|
|
RNA_def_function_return(func, parm);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* remove shader_fx */
|
|
|
|
|
func = RNA_def_function(srna, "remove", "rna_Object_shaderfx_remove");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
|
|
|
|
RNA_def_function_ui_description(func, "Remove an existing effect from the object");
|
|
|
|
|
/* shader to remove */
|
|
|
|
|
parm = RNA_def_pointer(func, "shader_fx", "ShaderFx", "", "Effect to remove");
|
|
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* clear all shader fx */
|
|
|
|
|
func = RNA_def_function(srna, "clear", "rna_Object_shaderfx_clear");
|
|
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
|
|
|
|
RNA_def_function_ui_description(func, "Remove all effects from the object");
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
/* object.particle_systems */
|
|
|
|
|
static void rna_def_object_particle_systems(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2023-09-25 16:56:17 +10:00
|
|
|
// FunctionRNA *func;
|
|
|
|
|
// PropertyRNA *parm;
|
2016-12-28 17:30:58 +01:00
|
|
|
|
|
|
|
|
RNA_def_property_srna(cprop, "ParticleSystems");
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ParticleSystems", nullptr);
|
2016-12-28 17:30:58 +01:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Particle Systems", "Collection of particle systems");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "ParticleSystem");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, "rna_Object_active_particle_system_get", nullptr, nullptr, nullptr);
|
2016-12-28 17:30:58 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Particle System", "Active particle system being displayed");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2018-06-09 14:40:09 +02:00
|
|
|
|
2016-12-28 17:30:58 +01:00
|
|
|
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
|
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Object_active_particle_system_index_get",
|
|
|
|
|
"rna_Object_active_particle_system_index_set",
|
|
|
|
|
"rna_Object_active_particle_system_index_range");
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Particle System Index", "Index of active particle system slot");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_particle_update");
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
/* object.vertex_groups */
|
|
|
|
|
static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_property_srna(cprop, "VertexGroups");
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "VertexGroups", nullptr);
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
|
|
|
|
RNA_def_struct_ui_text(srna, "Vertex Groups", "Collection of vertex groups");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_property_struct_type(prop, "VertexGroup");
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_Object_active_vertex_group_get",
|
|
|
|
|
"rna_Object_active_vertex_group_set",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2020-03-27 22:14:38 -03:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object");
|
2023-09-12 15:43:57 +02:00
|
|
|
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-11 14:11:46 +00:00
|
|
|
prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
|
2010-09-21 10:59:53 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Object_active_vertex_group_index_get",
|
|
|
|
|
"rna_Object_active_vertex_group_index_set",
|
2011-09-25 09:55:13 +00:00
|
|
|
"rna_Object_active_vertex_group_index_range");
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Active Vertex Group Index", "Active index in vertex group array");
|
2023-09-12 15:43:57 +02:00
|
|
|
RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
/* vertex groups */ /* add_vertex_group */
|
|
|
|
|
func = RNA_def_function(srna, "new", "rna_Object_vgroup_new");
|
2020-09-14 18:25:54 +10:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Add vertex group to object");
|
|
|
|
|
RNA_def_string(func, "name", "Group", 0, "", "Vertex group name"); /* optional */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "New vertex group");
|
2010-09-07 05:47:34 +00:00
|
|
|
RNA_def_function_return(func, parm);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "remove", "rna_Object_vgroup_remove");
|
2019-04-24 16:24:53 +03:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Delete vertex group from object");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove");
|
Refactor RNA property: split flags in property flags, parameter flags, and internal flags.
This gives us 9 flags available again for properties (we had none anymore),
and also makes things slightly cleaner.
To simplify (and make more clear the differences between mere properties
and function parameters), also added RNA_def_parameter_flags function (and
its clear counterpart), to be used instead of RNA_def_property_flag for
function parameters.
This patch is also a big cleanup (some RNA function definitions were
still using 'prop' PropertyRNA pointer, etc.).
And yes, am aware this will be annoying for all branches, but we really need
to get new flags available for properties (will need at least one for override, etc.).
Reviewers: sergey, Severin
Subscribers: dfelinto, brecht
Differential Revision: https://developer.blender.org/D2400
2016-12-12 15:23:55 +01:00
|
|
|
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
|
2023-06-14 15:27:59 +02:00
|
|
|
RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, ParameterFlag(0));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "rna_Object_vgroup_clear");
|
2021-07-16 12:23:55 -04:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
|
2011-11-23 16:12:11 +00:00
|
|
|
RNA_def_function_ui_description(func, "Delete all vertex groups from object");
|
2009-11-28 13:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-09 15:13:12 +02:00
|
|
|
static void rna_def_object_display(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectDisplay", nullptr);
|
2020-12-24 11:07:32 -06:00
|
|
|
RNA_def_struct_ui_text(srna, "Object Display", "Object display settings for 3D viewport");
|
2019-02-11 10:32:11 +11:00
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
|
|
|
|
RNA_def_struct_nested(brna, srna, "Object");
|
2018-05-13 19:06:37 +02:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ObjectDisplay_path");
|
2018-05-09 15:13:12 +02:00
|
|
|
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(true);
|
|
|
|
|
|
2018-05-09 15:13:12 +02:00
|
|
|
prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "dtx", OB_DRAW_NO_SHADOW_CAST);
|
2020-12-24 11:07:32 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Shadow", "Object cast shadows in the 3D viewport");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2020-06-30 16:06:08 +02:00
|
|
|
|
|
|
|
|
RNA_define_lib_overridable(false);
|
2018-05-09 15:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
static void rna_def_object_lineart(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2025-03-28 00:59:11 +00:00
|
|
|
static const EnumPropertyItem prop_feature_line_usage_items[] = {
|
2021-03-22 10:56:25 +01:00
|
|
|
{OBJECT_LRT_INHERIT, "INHERIT", 0, "Inherit", "Use settings from the parent collection"},
|
2021-03-17 13:46:41 -04:00
|
|
|
{OBJECT_LRT_INCLUDE,
|
|
|
|
|
"INCLUDE",
|
2021-03-16 19:35:53 +01:00
|
|
|
0,
|
2021-03-17 13:46:41 -04:00
|
|
|
"Include",
|
|
|
|
|
"Generate feature lines for this object's data"},
|
2021-03-16 19:35:53 +01:00
|
|
|
{OBJECT_LRT_OCCLUSION_ONLY,
|
|
|
|
|
"OCCLUSION_ONLY",
|
|
|
|
|
0,
|
|
|
|
|
"Occlusion Only",
|
2021-03-17 13:46:41 -04:00
|
|
|
"Only use the object data to produce occlusion"},
|
|
|
|
|
{OBJECT_LRT_EXCLUDE,
|
|
|
|
|
"EXCLUDE",
|
|
|
|
|
0,
|
|
|
|
|
"Exclude",
|
|
|
|
|
"Don't use this object for Line Art rendering"},
|
2021-03-16 19:35:53 +01:00
|
|
|
{OBJECT_LRT_INTERSECTION_ONLY,
|
|
|
|
|
"INTERSECTION_ONLY",
|
|
|
|
|
0,
|
|
|
|
|
"Intersection Only",
|
2021-03-17 13:46:41 -04:00
|
|
|
"Only generate intersection lines for this collection"},
|
2021-03-16 19:35:53 +01:00
|
|
|
{OBJECT_LRT_NO_INTERSECTION,
|
|
|
|
|
"NO_INTERSECTION",
|
|
|
|
|
0,
|
|
|
|
|
"No Intersection",
|
|
|
|
|
"Include this object but do not generate intersection lines"},
|
2022-09-15 22:02:14 +08:00
|
|
|
{OBJECT_LRT_FORCE_INTERSECTION,
|
|
|
|
|
"FORCE_INTERSECTION",
|
|
|
|
|
0,
|
|
|
|
|
"Force Intersection",
|
|
|
|
|
"Generate intersection lines even with objects that disabled intersection"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2021-03-16 19:35:53 +01:00
|
|
|
};
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectLineArt", nullptr);
|
2024-04-15 20:02:38 +02:00
|
|
|
RNA_def_struct_ui_text(srna, "Object Line Art", "Object Line Art settings");
|
2021-03-16 19:35:53 +01:00
|
|
|
RNA_def_struct_sdna(srna, "ObjectLineArt");
|
2022-11-25 23:15:05 +08:00
|
|
|
RNA_def_struct_path_func(srna, "rna_ObjectLineArt_path");
|
2021-03-16 19:35:53 +01:00
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "usage", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(prop, prop_feature_line_usage_items);
|
2024-04-15 20:02:38 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Usage", "How to use this object in Line Art calculation");
|
2021-03-16 19:35:53 +01:00
|
|
|
RNA_def_property_update(prop, 0, "rna_object_lineart_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_crease_override", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "flags", OBJECT_LRT_OWN_CREASE);
|
2021-03-17 13:46:41 -04:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Use Crease", "Use this object's crease setting to overwrite scene global");
|
2021-03-16 19:35:53 +01:00
|
|
|
RNA_def_property_update(prop, 0, "rna_object_lineart_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "crease_threshold", PROP_FLOAT, PROP_ANGLE);
|
|
|
|
|
RNA_def_property_range(prop, 0, DEG2RAD(180.0f));
|
|
|
|
|
RNA_def_property_ui_range(prop, 0.0f, DEG2RAD(180.0f), 0.01f, 1);
|
2021-03-17 13:46:41 -04:00
|
|
|
RNA_def_property_ui_text(prop, "Crease", "Angles smaller than this will be treated as creases");
|
2021-03-16 19:35:53 +01:00
|
|
|
RNA_def_property_update(prop, 0, "rna_object_lineart_update");
|
2022-06-29 22:54:29 +08:00
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_intersection_priority_override", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "flags", OBJECT_LRT_OWN_INTERSECTION_PRIORITY);
|
2022-06-29 22:54:29 +08:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Use Intersection Priority",
|
|
|
|
|
"Use this object's intersection priority to override collection setting");
|
|
|
|
|
RNA_def_property_update(prop, 0, "rna_object_lineart_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "intersection_priority", PROP_INT, PROP_NONE);
|
|
|
|
|
RNA_def_property_range(prop, 0, 255);
|
|
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Intersection Priority",
|
|
|
|
|
"The intersection line will be included into the object with the "
|
|
|
|
|
"higher intersection priority value");
|
|
|
|
|
RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, "rna_object_lineart_update");
|
2021-03-16 19:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-04 17:46:55 +02:00
|
|
|
static void rna_def_object_visibility(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* Hide options. */
|
|
|
|
|
prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_VIEWPORT);
|
2021-08-04 17:46:55 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Disable in Viewports", "Globally disable in viewports");
|
|
|
|
|
RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SELECT);
|
2021-08-04 17:46:55 +02:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Disable Selection", "Disable selection in viewport");
|
|
|
|
|
RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_RENDER);
|
2021-08-04 17:46:55 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders");
|
|
|
|
|
RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
|
|
|
|
|
|
2023-09-26 20:37:15 +02:00
|
|
|
prop = RNA_def_property(srna, "hide_probe_volume", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_VOLUME);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Disable in Volume Probes", "Globally disable in volume probes");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
2023-11-22 14:43:52 +01:00
|
|
|
prop = RNA_def_property(srna, "hide_probe_sphere", PROP_BOOLEAN, PROP_NONE);
|
2023-09-26 20:37:15 +02:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_CUBEMAP);
|
|
|
|
|
RNA_def_property_ui_text(
|
2023-11-22 14:43:52 +01:00
|
|
|
prop, "Disable in Spherical Light Probes", "Globally disable in spherical light probes");
|
2023-09-26 20:37:15 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
2023-11-22 14:43:52 +01:00
|
|
|
prop = RNA_def_property(srna, "hide_probe_plane", PROP_BOOLEAN, PROP_NONE);
|
2023-10-08 19:49:58 +02:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_PROBE_PLANAR);
|
2023-11-22 14:43:52 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Disable in Planar Light Probes", "Globally disable in planar light probes");
|
2023-10-08 19:49:58 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
2025-10-16 19:17:18 +02:00
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "hide_surface_pick", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SURFACE_PICK);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Disable in Surface Picking",
|
|
|
|
|
"Disable surface influence during selection, snapping and depth-picking operators. "
|
|
|
|
|
"Usually used to avoid semi-transparent objects to affect scene navigation");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
2023-10-08 19:49:58 +02:00
|
|
|
|
2021-08-04 17:46:55 +02:00
|
|
|
/* Instancer options. */
|
|
|
|
|
prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER);
|
2021-08-04 17:46:55 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Render Instancer", "Make instancer visible when rendering");
|
|
|
|
|
RNA_def_property_update(
|
|
|
|
|
prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "show_instancer_for_viewport", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(
|
|
|
|
|
prop, nullptr, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT);
|
2021-08-04 17:46:55 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Instancer", "Make instancer visible in the viewport");
|
|
|
|
|
RNA_def_property_update(
|
|
|
|
|
prop, NC_OBJECT | ND_DRAW, "rna_Object_duplicator_visibility_flag_update");
|
2021-08-04 19:43:40 +02:00
|
|
|
|
|
|
|
|
/* Ray visibility. */
|
|
|
|
|
prop = RNA_def_property(srna, "visible_camera", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_CAMERA);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Camera Visibility", "Object visibility to camera rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "visible_diffuse", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_DIFFUSE);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Diffuse Visibility", "Object visibility to diffuse rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "visible_glossy", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_GLOSSY);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Glossy Visibility", "Object visibility to glossy rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "visible_transmission", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_TRANSMISSION);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Transmission Visibility", "Object visibility to transmission rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "visible_volume_scatter", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_VOLUME_SCATTER);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Volume Scatter Visibility", "Object visibility to volume scattering rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "visible_shadow", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_negative_sdna(prop, nullptr, "visibility_flag", OB_HIDE_SHADOW);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Shadow Visibility", "Object visibility to shadow rays");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
|
|
|
|
|
|
|
|
|
/* Holdout and shadow catcher. */
|
|
|
|
|
prop = RNA_def_property(srna, "is_holdout", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_HOLDOUT);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Holdout",
|
|
|
|
|
"Render objects as a holdout or matte, creating a hole in the image with zero alpha, to "
|
|
|
|
|
"fill out in compositing with real footage or another render");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "is_shadow_catcher", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "visibility_flag", OB_SHADOW_CATCHER);
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Shadow Catcher",
|
|
|
|
|
"Only render shadows and reflections on this object, for compositing renders into real "
|
|
|
|
|
"footage. Objects with this setting are considered to already exist in the footage, "
|
2024-08-01 00:55:02 +02:00
|
|
|
"objects without it are synthetic objects being composited into it.");
|
2021-08-04 19:43:40 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
2021-08-04 17:46:55 +02:00
|
|
|
}
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
static void rna_def_object(BlenderRNA *brna)
|
2008-10-31 23:50:02 +00:00
|
|
|
{
|
2008-11-07 02:58:25 +00:00
|
|
|
StructRNA *srna;
|
2008-10-31 23:50:02 +00:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem up_items[] = {
|
2009-06-16 00:52:21 +00:00
|
|
|
{OB_POSX, "X", 0, "X", ""},
|
|
|
|
|
{OB_POSY, "Y", 0, "Y", ""},
|
|
|
|
|
{OB_POSZ, "Z", 0, "Z", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem drawtype_items[] = {
|
2018-09-03 18:58:41 +02:00
|
|
|
{OB_BOUNDBOX, "BOUNDS", 0, "Bounds", "Display the bounds of the object"},
|
|
|
|
|
{OB_WIRE, "WIRE", 0, "Wire", "Display the object as a wireframe"},
|
|
|
|
|
{OB_SOLID,
|
|
|
|
|
"SOLID",
|
|
|
|
|
0,
|
|
|
|
|
"Solid",
|
|
|
|
|
"Display the object as a solid (if solid drawing is enabled in the viewport)"},
|
2019-02-28 16:51:10 +01:00
|
|
|
{OB_TEXTURE,
|
|
|
|
|
"TEXTURED",
|
|
|
|
|
0,
|
|
|
|
|
"Textured",
|
|
|
|
|
"Display the object with textures (if textures are enabled in the viewport)"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem boundtype_items[] = {
|
2018-09-03 18:58:41 +02:00
|
|
|
{OB_BOUND_BOX, "BOX", 0, "Box", "Display bounds as box"},
|
|
|
|
|
{OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Display bounds as sphere"},
|
|
|
|
|
{OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Display bounds as cylinder"},
|
|
|
|
|
{OB_BOUND_CONE, "CONE", 0, "Cone", "Display bounds as cone"},
|
|
|
|
|
{OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Display bounds as capsule"},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2012-05-12 11:01:29 +00:00
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
static int boundbox_dimsize[] = {8, 3};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
srna = RNA_def_struct(brna, "Object", "ID");
|
2015-10-24 02:44:43 +11:00
|
|
|
RNA_def_struct_ui_text(srna, "Object", "Object data-block defining an object in a scene");
|
2009-05-29 15:12:31 +00:00
|
|
|
RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
|
2009-06-03 23:16:51 +00:00
|
|
|
RNA_def_struct_ui_icon(srna, ICON_OBJECT_DATA);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(true);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ID");
|
2025-02-25 10:46:27 +01:00
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, "rna_Object_data_get", "rna_Object_data_set", "rna_Object_data_typef", nullptr);
|
2018-06-05 11:10:05 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Data", "Object data");
|
2020-12-29 14:43:12 +01:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Object_data_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "type");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_type_items);
|
2009-07-14 20:27:28 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2020-12-24 11:07:32 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Type", "Type of object");
|
2019-02-12 22:13:42 +01:00
|
|
|
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_ID);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-05 18:20:27 +02:00
|
|
|
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "mode");
|
2018-04-05 18:20:27 +02:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_mode_items);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Mode", "Object interaction mode");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-02-10 20:29:40 +00:00
|
|
|
/* for data access */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "bound_box", PROP_FLOAT, PROP_NONE);
|
2010-02-10 20:29:40 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, boundbox_dimsize);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2021-03-26 16:12:30 +01:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_funcs(prop, "rna_Object_boundbox_get", nullptr, nullptr);
|
2011-09-24 09:57:47 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Bounding Box",
|
2012-03-18 09:27:36 +00:00
|
|
|
"Object's bounding box in object-space coordinates, all values are -1.0 when "
|
|
|
|
|
"not available");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-03-26 02:57:49 +00:00
|
|
|
/* parent */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, nullptr, "rna_Object_parent_set", nullptr, nullptr);
|
2018-06-05 11:10:05 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_override_apply");
|
2020-12-24 11:07:32 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Parent", "Parent object");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "parent_type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "partype");
|
2009-01-02 13:47:33 +00:00
|
|
|
RNA_def_property_enum_items(prop, parent_type_items);
|
2009-07-14 20:27:28 +00:00
|
|
|
RNA_def_property_enum_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, nullptr, "rna_Object_parent_type_set", "rna_Object_parent_type_itemf");
|
2023-07-04 17:06:05 +02:00
|
|
|
RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_type_override_apply");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Parent Type", "Type of parent relation");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "parent_vertices", PROP_INT, PROP_UNSIGNED);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_sdna(prop, nullptr, "par1");
|
2009-01-02 13:47:33 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2011-09-24 09:57:47 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Parent Vertices", "Indices of vertices in case of a vertex parenting relation");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_string_sdna(prop, nullptr, "parsubstr");
|
|
|
|
|
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Object_parent_bone_set");
|
2023-07-04 17:06:05 +02:00
|
|
|
RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_parent_bone_override_apply");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Parent Bone", "Name of parent bone in case of a bone parenting relation");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-03-21 23:43:48 +01:00
|
|
|
prop = RNA_def_property(srna, "use_parent_final_indices", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_PARENT_USE_FINAL_INDICES);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Use Final Indices",
|
|
|
|
|
"Use the final evaluated indices rather than the original mesh indices");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
|
|
|
|
|
2020-11-05 16:08:00 -06:00
|
|
|
prop = RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, nullptr, "transflag", OB_TRANSFORM_ADJUST_ROOT_PARENT_FOR_VIEW_LOCK);
|
2020-11-05 16:08:00 -06:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Camera Parent Lock",
|
|
|
|
|
"View Lock 3D viewport camera transformation affects the object's "
|
|
|
|
|
"parent instead");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
|
|
|
|
|
2010-03-26 02:57:49 +00:00
|
|
|
/* Track and Up flags */
|
2012-03-18 09:27:36 +00:00
|
|
|
/* XXX: these have been saved here for a bit longer (after old track was removed),
|
|
|
|
|
* since some other tools still refer to this */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "trackflag");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Track Axis",
|
2020-12-11 14:06:07 +01:00
|
|
|
"Axis that points in the 'forward' direction (applies to Instance Vertices when "
|
|
|
|
|
"Align to Vertex Normal is enabled)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "upflag");
|
2009-01-02 16:58:09 +00:00
|
|
|
RNA_def_property_enum_items(prop, up_items);
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Up Axis",
|
2020-12-11 14:06:07 +01:00
|
|
|
"Axis that points in the upward direction (applies to Instance Vertices when "
|
|
|
|
|
"Align to Vertex Normal is enabled)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-02 13:47:33 +00:00
|
|
|
/* materials */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "material_slots", PROP_COLLECTION, PROP_NONE);
|
2009-06-03 23:22:43 +00:00
|
|
|
RNA_def_property_struct_type(prop, "MaterialSlot");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_PROP_NAME);
|
2021-05-19 10:23:09 +02:00
|
|
|
/* Don't dereference the material slot pointer, it is the slot index encoded in a pointer. */
|
|
|
|
|
RNA_def_property_collection_funcs(prop,
|
|
|
|
|
"rna_Object_material_slots_begin",
|
|
|
|
|
"rna_Object_material_slots_next",
|
|
|
|
|
"rna_Object_material_slots_end",
|
|
|
|
|
"rna_Object_material_slots_get",
|
|
|
|
|
"rna_Object_material_slots_length",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Material Slots", "Material slots in the object");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE);
|
2009-07-28 18:54:02 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Material");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_Object_active_material_get",
|
2018-07-31 10:22:19 +02:00
|
|
|
"rna_Object_active_material_set",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
2018-07-31 10:22:19 +02:00
|
|
|
"rna_MaterialSlot_material_poll");
|
2025-08-01 18:17:08 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
|
2014-05-29 16:16:31 +10:00
|
|
|
RNA_def_property_editable_func(prop, "rna_Object_active_material_editable");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_MaterialSlot_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_sdna(prop, nullptr, "actcol");
|
2022-11-25 17:24:33 +01:00
|
|
|
RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
|
2010-09-21 10:59:53 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Object_active_material_index_get",
|
|
|
|
|
"rna_Object_active_material_index_set",
|
|
|
|
|
"rna_Object_active_material_index_range");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Material Index", "Index of active material slot");
|
2025-02-25 10:46:27 +01:00
|
|
|
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
/* transform */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "loc");
|
2009-11-25 12:00:31 +00:00
|
|
|
RNA_def_property_editable_array_func(prop, "rna_Object_location_editable");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Location", "Location of the object");
|
2012-04-10 08:33:30 +00:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "quat");
|
2009-11-25 12:00:31 +00:00
|
|
|
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Quaternion Rotation", "Rotation in Quaternions");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
/* XXX: for axis-angle, it would have been nice to have 2 separate fields for UI purposes, but
|
|
|
|
|
* having a single one is better for Keyframing and other property-management situations...
|
|
|
|
|
*/
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
|
2010-01-07 22:54:05 +00:00
|
|
|
RNA_def_property_array(prop, 4);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_float_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_Object_rotation_axis_angle_get", "rna_Object_rotation_axis_angle_set", nullptr);
|
2009-11-25 12:00:31 +00:00
|
|
|
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_4d_editable");
|
2019-03-01 13:21:08 +11:00
|
|
|
RNA_def_property_float_array_default(prop, rna_default_axis_angle);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Axis-Angle Rotation", "Angle of Rotation for Axis-Angle rotation representation");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "rotation_euler", PROP_FLOAT, PROP_EULER);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "rot");
|
2009-11-25 12:00:31 +00:00
|
|
|
RNA_def_property_editable_array_func(prop, "rna_Object_rotation_euler_editable");
|
2023-05-19 00:25:05 +02:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, RNA_TRANSLATION_PREC_DEFAULT);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Euler Rotation", "Rotation in Eulers");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "rotmode");
|
2019-01-16 11:16:15 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_rotation_mode_items);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_funcs(prop, nullptr, "rna_Object_rotation_mode_set", nullptr);
|
2025-03-18 22:39:30 +11:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Rotation Mode",
|
|
|
|
|
/* This description is shared by other "rotation_mode" properties. */
|
2025-08-05 11:16:22 +02:00
|
|
|
"The kind of rotation to apply, values from other rotation modes are not used");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
|
2018-06-05 11:10:05 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2009-11-25 12:00:31 +00:00
|
|
|
RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");
|
2010-09-16 04:19:22 +00:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Scale", "Scaling of the object");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ_LENGTH);
|
2009-11-04 23:14:20 +00:00
|
|
|
RNA_def_property_array(prop, 3);
|
2019-08-01 13:53:25 +10:00
|
|
|
/* Only as convenient helper for py API, and conflicts with animating scale. */
|
2019-01-05 16:33:38 +01:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2019-01-05 16:33:38 +01:00
|
|
|
RNA_def_property_float_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", nullptr);
|
2017-09-14 16:34:05 +02:00
|
|
|
RNA_def_property_ui_range(prop, 0.0f, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
2021-03-27 14:49:59 +11:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Dimensions",
|
|
|
|
|
"Absolute bounding box dimensions of the object.\n"
|
|
|
|
|
"Warning: Assigning to it or its members multiple consecutive times "
|
|
|
|
|
"will not work correctly, as this needs up-to-date evaluated data");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* delta transforms */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "dloc");
|
2010-02-17 16:18:41 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Delta Location", "Extra translation added to the location of the object");
|
2012-04-10 08:33:30 +00:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "delta_rotation_euler", PROP_FLOAT, PROP_EULER);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "drot");
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Delta Rotation (Euler)",
|
|
|
|
|
"Extra rotation added to the rotation of the object (when using Euler rotations)");
|
2023-05-19 00:25:05 +02:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 100, RNA_TRANSLATION_PREC_DEFAULT);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "delta_rotation_quaternion", PROP_FLOAT, PROP_QUATERNION);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "dquat");
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Delta Rotation (Quaternion)",
|
|
|
|
|
"Extra rotation added to the rotation of the object (when using Quaternion rotations)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
# if 0 /* XXX not supported well yet... */
|
|
|
|
|
prop = RNA_def_property(srna, "delta_rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
|
2012-05-12 11:01:29 +00:00
|
|
|
/* FIXME: this is not a single field any more! (drotAxis and drotAngle) */
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "dquat");
|
2019-03-01 13:21:08 +11:00
|
|
|
RNA_def_property_float_array_default(prop, rna_default_axis_angle);
|
2019-04-17 08:50:46 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Delta Rotation (Axis Angle)",
|
|
|
|
|
"Extra rotation added to the rotation of the object (when using Axis-Angle rotations)");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2009-10-22 23:22:05 +00:00
|
|
|
# endif
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "delta_scale", PROP_FLOAT, PROP_XYZ);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "dscale");
|
2014-02-09 08:42:45 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
|
2011-12-11 00:01:04 +00:00
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
|
2010-02-17 16:18:41 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Delta Scale", "Extra scaling added to the scale of the object");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-10-22 23:22:05 +00:00
|
|
|
/* transform locks */
|
2012-04-10 08:33:30 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_location", PROP_BOOLEAN, PROP_NONE);
|
Refactor: RNA definition of Boolean bitset/bitflags properties.
Existing code had several issues:
* The 'DNA bitset as RNA array' behavior was totally undocumented,
virtually impossible to discover, very confusing, and without any
checks that given parameters (like the array length) were valid.
* The DNA defaults handling was fully broken for 'negative' boolean
properties.
This commit:
* Factorizes all rna define code for boolean properties storing a `booleanbit`
value into a new static util (this revealed and fixed the 'negative defaults'
issue).
* Forbids calling `RNA_def_property_array` on a Boolean property with a
non-null `booleanbit` value.
* Introduces a new `RNA_def_property_boolean_bitset_array_sdna`,
strictly to define 'DNA bitsets as RNA array' properties.
* Adds several validation checks, in particular regarding the bitset
case: it takes into account the fact that bitshift operations on
negative numbers are typically
[arithmetic ones](https://en.cppreference.com/w/cpp/language/operator_arithmetic),
which means that they preserve the sign of the value, and that the
left-most bit should never be used with signed integers for bitsets.
-------------------
The fix to DNA defaults handling on 'negative' properties revealed
several RNA errors, listed below. Fixing them is not necessarily trivial
(as some seem to contradict the DNA default values, e.g. the
`View3DShading.use_studiolight_view_rotation` one), so it is kept
outside of this refactor. Conflicting cases should likely be handled by
the relevant modules (to decide whether the DNA, or the RNA default
should be kept).
-------------------
Also realized that many DNA types are ignored when trying to find DNA
default values. This will also be tackled separately, as fixing it is
fairly straightforward.
Pull Request: https://projects.blender.org/blender/blender/pulls/132917
2025-01-14 18:19:27 +01:00
|
|
|
RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_LOCX, 3);
|
2020-01-22 02:50:28 +11:00
|
|
|
RNA_def_property_ui_text(prop, "Lock Location", "Lock editing of location when transforming");
|
2010-05-07 04:52:10 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-10 08:33:30 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_rotation", PROP_BOOLEAN, PROP_NONE);
|
Refactor: RNA definition of Boolean bitset/bitflags properties.
Existing code had several issues:
* The 'DNA bitset as RNA array' behavior was totally undocumented,
virtually impossible to discover, very confusing, and without any
checks that given parameters (like the array length) were valid.
* The DNA defaults handling was fully broken for 'negative' boolean
properties.
This commit:
* Factorizes all rna define code for boolean properties storing a `booleanbit`
value into a new static util (this revealed and fixed the 'negative defaults'
issue).
* Forbids calling `RNA_def_property_array` on a Boolean property with a
non-null `booleanbit` value.
* Introduces a new `RNA_def_property_boolean_bitset_array_sdna`,
strictly to define 'DNA bitsets as RNA array' properties.
* Adds several validation checks, in particular regarding the bitset
case: it takes into account the fact that bitshift operations on
negative numbers are typically
[arithmetic ones](https://en.cppreference.com/w/cpp/language/operator_arithmetic),
which means that they preserve the sign of the value, and that the
left-most bit should never be used with signed integers for bitsets.
-------------------
The fix to DNA defaults handling on 'negative' properties revealed
several RNA errors, listed below. Fixing them is not necessarily trivial
(as some seem to contradict the DNA default values, e.g. the
`View3DShading.use_studiolight_view_rotation` one), so it is kept
outside of this refactor. Conflicting cases should likely be handled by
the relevant modules (to decide whether the DNA, or the RNA default
should be kept).
-------------------
Also realized that many DNA types are ignored when trying to find DNA
default values. This will also be tackled separately, as fixing it is
fairly straightforward.
Pull Request: https://projects.blender.org/blender/blender/pulls/132917
2025-01-14 18:19:27 +01:00
|
|
|
RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTX, 3);
|
2020-01-22 02:50:28 +11:00
|
|
|
RNA_def_property_ui_text(prop, "Lock Rotation", "Lock editing of rotation when transforming");
|
2010-05-07 04:52:10 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 11:01:29 +00:00
|
|
|
/* XXX this is sub-optimal - it really should be included above,
|
|
|
|
|
* but due to technical reasons we can't do this! */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_rotation_w", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROTW);
|
2010-05-07 04:52:10 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Lock Rotation (4D Angle)",
|
2020-01-22 02:50:28 +11:00
|
|
|
"Lock editing of 'angle' component of four-component rotations when transforming");
|
2012-05-12 11:01:29 +00:00
|
|
|
/* XXX this needs a better name */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_rotations_4d", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "protectflag", OB_LOCK_ROT4D);
|
2011-09-25 09:55:13 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Lock Rotations (4D)",
|
|
|
|
|
"Lock editing of four component rotations by components (instead of as Eulers)");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-10 08:33:30 +00:00
|
|
|
prop = RNA_def_property(srna, "lock_scale", PROP_BOOLEAN, PROP_NONE);
|
Refactor: RNA definition of Boolean bitset/bitflags properties.
Existing code had several issues:
* The 'DNA bitset as RNA array' behavior was totally undocumented,
virtually impossible to discover, very confusing, and without any
checks that given parameters (like the array length) were valid.
* The DNA defaults handling was fully broken for 'negative' boolean
properties.
This commit:
* Factorizes all rna define code for boolean properties storing a `booleanbit`
value into a new static util (this revealed and fixed the 'negative defaults'
issue).
* Forbids calling `RNA_def_property_array` on a Boolean property with a
non-null `booleanbit` value.
* Introduces a new `RNA_def_property_boolean_bitset_array_sdna`,
strictly to define 'DNA bitsets as RNA array' properties.
* Adds several validation checks, in particular regarding the bitset
case: it takes into account the fact that bitshift operations on
negative numbers are typically
[arithmetic ones](https://en.cppreference.com/w/cpp/language/operator_arithmetic),
which means that they preserve the sign of the value, and that the
left-most bit should never be used with signed integers for bitsets.
-------------------
The fix to DNA defaults handling on 'negative' properties revealed
several RNA errors, listed below. Fixing them is not necessarily trivial
(as some seem to contradict the DNA default values, e.g. the
`View3DShading.use_studiolight_view_rotation` one), so it is kept
outside of this refactor. Conflicting cases should likely be handled by
the relevant modules (to decide whether the DNA, or the RNA default
should be kept).
-------------------
Also realized that many DNA types are ignored when trying to find DNA
default values. This will also be tackled separately, as fixing it is
fairly straightforward.
Pull Request: https://projects.blender.org/blender/blender/pulls/132917
2025-01-14 18:19:27 +01:00
|
|
|
RNA_def_property_boolean_bitset_array_sdna(prop, nullptr, "protectflag", OB_LOCK_SCALEX, 3);
|
2020-01-22 02:50:28 +11:00
|
|
|
RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale when transforming");
|
2010-05-07 04:52:10 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_UNLOCKED, 1);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
/* matrix */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
|
2010-11-30 20:22:26 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2024-02-14 16:14:49 +01:00
|
|
|
RNA_def_property_float_funcs(
|
|
|
|
|
prop, "rna_Object_matrix_world_get", "rna_Object_matrix_world_set", nullptr);
|
2010-07-03 17:39:29 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Matrix World", "Worldspace transformation matrix");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_matrix_world_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX);
|
2010-11-30 20:22:26 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2014-12-20 14:14:36 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Local Matrix",
|
2021-03-26 12:07:50 -04:00
|
|
|
"Parent relative transformation matrix.\n"
|
|
|
|
|
"Warning: Only takes into account object parenting, so e.g. in case of bone parenting "
|
2014-12-20 14:14:36 +01:00
|
|
|
"you get a matrix relative to the Armature object, not to the actual parent bone");
|
2010-07-03 17:39:29 +00:00
|
|
|
RNA_def_property_float_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_Object_matrix_local_get", "rna_Object_matrix_local_set", nullptr);
|
2018-12-04 12:04:27 +01:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
|
2010-11-30 20:22:26 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Input Matrix",
|
|
|
|
|
"Matrix access to location, rotation and scale (including deltas), "
|
|
|
|
|
"before constraints and parenting are applied");
|
2010-11-15 06:38:07 +00:00
|
|
|
RNA_def_property_float_funcs(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, "rna_Object_matrix_basis_get", "rna_Object_matrix_basis_set", nullptr);
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-04-13 13:46:22 +10:00
|
|
|
/* Parent_inverse. */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "matrix_parent_inverse", PROP_FLOAT, PROP_MATRIX);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "parentinv");
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
|
|
|
|
|
RNA_def_property_ui_text(
|
2019-09-28 10:14:46 +03:00
|
|
|
prop, "Parent Inverse Matrix", "Inverse of object's parent matrix at time of parenting");
|
2018-05-02 18:13:15 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 10:22:19 +02:00
|
|
|
/* modifiers */
|
|
|
|
|
prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "Modifier");
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Modifiers", "Modifiers affecting the geometric data of the object");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_modifiers_override_apply");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_LIBRARY_INSERTION);
|
2018-07-31 10:22:19 +02:00
|
|
|
rna_def_object_modifiers(brna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-11 21:27:14 +00:00
|
|
|
/* Shader FX. */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "shader_effects", PROP_COLLECTION, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_collection_sdna(prop, nullptr, "shader_fx", nullptr);
|
2009-01-01 20:44:40 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ShaderFx");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Shader Effects", "Effects affecting display of object");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(false);
|
2010-09-07 05:47:34 +00:00
|
|
|
rna_def_object_shaderfxs(brna, prop);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-30 17:58:24 +10:00
|
|
|
/* constraints */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE);
|
2008-12-12 23:30:23 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Constraint");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_LIBRARY_INSERTION);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(
|
2017-05-30 17:58:24 +10:00
|
|
|
prop, "Constraints", "Constraints affecting the transformation of the object");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_override_funcs(prop, nullptr, nullptr, "rna_Object_constraints_override_apply");
|
2019-04-22 02:48:05 +10:00
|
|
|
# if 0
|
2023-08-09 10:47:43 +10:00
|
|
|
RNA_def_property_collection_funcs(prop,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
"constraints__add",
|
|
|
|
|
"constraints__remove");
|
2019-04-22 02:48:05 +10:00
|
|
|
# endif
|
2009-11-13 16:08:03 +00:00
|
|
|
rna_def_object_constraints(brna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
/* vertex groups */
|
2017-05-30 17:58:24 +10:00
|
|
|
prop = RNA_def_property(srna, "vertex_groups", PROP_COLLECTION, PROP_NONE);
|
2021-07-13 12:10:34 -04:00
|
|
|
RNA_def_property_collection_funcs(prop,
|
|
|
|
|
"rna_Object_vertex_groups_begin",
|
|
|
|
|
"rna_iterator_listbase_next",
|
|
|
|
|
"rna_iterator_listbase_end",
|
|
|
|
|
"rna_iterator_listbase_get",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2017-05-30 17:58:24 +10:00
|
|
|
RNA_def_property_struct_type(prop, "VertexGroup");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2011-08-15 17:29:07 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object");
|
2010-09-07 05:47:34 +00:00
|
|
|
rna_def_object_vertex_groups(brna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-02 13:47:33 +00:00
|
|
|
/* empty */
|
2018-09-03 18:58:41 +02:00
|
|
|
prop = RNA_def_property(srna, "empty_display_type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "empty_drawtype");
|
2015-11-23 13:49:52 +11:00
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_empty_drawtype_items);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_funcs(prop, nullptr, "rna_Object_empty_display_type_set", nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Empty Display Type", "Viewport display style for empties");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-03 18:58:41 +02:00
|
|
|
prop = RNA_def_property(srna, "empty_display_size", PROP_FLOAT, PROP_DISTANCE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "empty_drawsize");
|
2010-04-28 21:18:40 +00:00
|
|
|
RNA_def_property_range(prop, 0.0001f, 1000.0f);
|
|
|
|
|
RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
|
2010-02-24 03:58:26 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Empty Display Size", "Size of display for empties in the viewport");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-06 05:48:16 +00:00
|
|
|
prop = RNA_def_property(srna, "empty_image_offset", PROP_FLOAT, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "ima_ofs");
|
2011-05-09 16:31:54 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Origin Offset", "Origin offset distance");
|
|
|
|
|
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1f, 2);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-13 21:57:05 +01:00
|
|
|
prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "iuser");
|
2014-01-13 21:57:05 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
2014-01-16 19:15:53 +11:00
|
|
|
"Image User",
|
2014-01-13 21:57:05 +01:00
|
|
|
"Parameters defining which layer, pass and frame of the image is displayed");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-31 13:35:53 +01:00
|
|
|
prop = RNA_def_property(srna, "empty_image_depth", PROP_ENUM, PROP_NONE);
|
|
|
|
|
RNA_def_property_enum_items(prop, rna_enum_object_empty_image_depth_items);
|
|
|
|
|
RNA_def_property_ui_text(
|
2018-12-17 13:21:49 +11:00
|
|
|
prop, "Empty Image Depth", "Determine which other objects will occlude the image");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-31 13:35:53 +01:00
|
|
|
prop = RNA_def_property(srna, "show_empty_image_perspective", PROP_BOOLEAN, PROP_NONE);
|
2018-12-17 13:21:49 +11:00
|
|
|
RNA_def_property_boolean_negative_sdna(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_PERSPECTIVE);
|
2018-10-31 13:35:53 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Display in Perspective Mode", "Display image in perspective mode");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-22 01:07:24 +11:00
|
|
|
prop = RNA_def_property(srna, "show_empty_image_orthographic", PROP_BOOLEAN, PROP_NONE);
|
2019-03-20 16:33:17 +01:00
|
|
|
RNA_def_property_boolean_negative_sdna(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC);
|
2019-03-20 16:33:17 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Display in Orthographic Mode", "Display image in orthographic mode");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-09-03 18:55:26 +10:00
|
|
|
prop = RNA_def_property(srna, "show_empty_image_only_axis_aligned", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_sdna(
|
2023-06-14 14:55:44 -04:00
|
|
|
prop, nullptr, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED);
|
2019-09-03 18:55:26 +10:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Display Only Axis Aligned",
|
|
|
|
|
"Only display the image when it is aligned with the view axis");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-09-03 18:55:26 +10:00
|
|
|
|
2018-12-17 14:49:16 +11:00
|
|
|
prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
|
2018-12-17 14:49:16 +11:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Use Alpha",
|
|
|
|
|
"Use alpha blending instead of alpha test (can produce sorting artifacts)");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-03-28 00:59:11 +00:00
|
|
|
static const EnumPropertyItem prop_empty_image_side_items[] = {
|
2012-03-05 23:30:41 +00:00
|
|
|
{0, "DOUBLE_SIDED", 0, "Both", ""},
|
2018-12-17 14:49:16 +11:00
|
|
|
{OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
|
2012-03-05 23:30:41 +00:00
|
|
|
{OB_EMPTY_IMAGE_HIDE_FRONT, "BACK", 0, "Back", ""},
|
2023-06-14 14:55:44 -04:00
|
|
|
{0, nullptr, 0, nullptr, nullptr},
|
2019-04-17 06:17:24 +02:00
|
|
|
};
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "empty_image_side", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "empty_image_visibility_flag");
|
2016-08-30 22:05:27 +02:00
|
|
|
RNA_def_property_enum_items(prop, prop_empty_image_side_items);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Empty Image Side", "Show front/back side");
|
I18n: disambiguate a few messages
- "Front"/"Back": 'put something at the front/back' or 'the front/back
face of something'. (e. g. the Empty Image options, Depth and Side
option, both use the same strings as enum, which should be avoided
in some languages).
- "Flip": invert, as in normals, or mirror, as in an image.
- "Path": a path to a resource, in general a file but sometimes a
datablock, as opposed to a trajectory in space.
- "Join": disambiguate for the Grease Pencil operator, which may use a
different word as that for meshes.
- "Wave": an ondulating motion, as opposed to a fluid dynamics motion.
- "Step": can mean the distance between two things, or a number of
times to do something. In this case it is better to use the plural.
- "Edge": generally the edges of a mesh, but can also mean edge
detection. Additionally, it was used for the option to enable
Freestyle. This was changed to "Use Freestyle".
- "Boundary": the limit of a grease pencil drawing for filling
purposes, as opposed to the external limit of a (non-manifold) mesh.
- "Rotations": can be translated to something like "Turns", in the
context of a spiral.
Pull Request: https://projects.blender.org/blender/blender/pulls/108213
2023-05-16 19:16:02 +02:00
|
|
|
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_IMAGE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-07-08 14:45:48 +02:00
|
|
|
prop = RNA_def_property(srna, "add_rest_position_attribute", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(
|
|
|
|
|
prop, nullptr, "modifier_flag", OB_MODIFIER_FLAG_ADD_REST_POSITION);
|
2022-07-08 14:45:48 +02:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Add Rest Position",
|
|
|
|
|
"Add a \"rest_position\" attribute that is a copy of the position "
|
|
|
|
|
"attribute before shape keys and modifiers are evaluated");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_data");
|
|
|
|
|
|
2009-01-02 13:47:33 +00:00
|
|
|
/* render */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_sdna(prop, nullptr, "index");
|
2009-01-02 13:47:33 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Pass Index", "Index number for the \"Object Index\" render pass");
|
2010-08-03 05:14:59 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT, "rna_Object_internal_update_draw");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-08-03 05:14:59 +00:00
|
|
|
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
|
2011-09-24 09:57:47 +00:00
|
|
|
RNA_def_property_ui_text(
|
2023-05-24 16:33:33 +02:00
|
|
|
prop, "Color", "Object color and alpha, used when the Object Color mode is enabled");
|
2019-08-22 14:26:09 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update_draw");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
/* physics */
|
|
|
|
|
prop = RNA_def_property(srna, "field", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "pd");
|
2009-01-02 13:47:33 +00:00
|
|
|
RNA_def_property_struct_type(prop, "FieldSettings");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Object_field_get", nullptr, nullptr, nullptr);
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Field Settings", "Settings for using the object as a field in physics simulation");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "collision", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "pd");
|
2009-11-03 02:49:36 +00:00
|
|
|
RNA_def_property_struct_type(prop, "CollisionSettings");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Object_collision_get", nullptr, nullptr, nullptr);
|
2016-12-28 17:30:58 +01:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Collision Settings",
|
|
|
|
|
"Settings for using the object as a collider in physics simulation");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-23 05:56:22 +00:00
|
|
|
prop = RNA_def_property(srna, "soft_body", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "soft");
|
2013-01-23 05:56:22 +00:00
|
|
|
RNA_def_property_struct_type(prop, "SoftBodySettings");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Soft Body Settings", "Settings for soft body simulation");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-23 05:56:22 +00:00
|
|
|
prop = RNA_def_property(srna, "particle_systems", PROP_COLLECTION, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_collection_sdna(prop, nullptr, "particlesystem", nullptr);
|
2013-01-23 05:56:56 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ParticleSystem");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object");
|
2016-12-28 17:30:58 +01:00
|
|
|
rna_def_object_particle_systems(brna, prop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-23 05:56:56 +00:00
|
|
|
prop = RNA_def_property(srna, "rigid_body", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "rigidbody_object");
|
2013-01-23 05:56:56 +00:00
|
|
|
RNA_def_property_struct_type(prop, "RigidBodyObject");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Rigid Body Settings", "Settings for rigid body simulation");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-18 19:18:02 +02:00
|
|
|
prop = RNA_def_property(srna, "rigid_body_constraint", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "rigidbody_constraint");
|
2018-08-18 10:08:28 +02:00
|
|
|
RNA_def_property_struct_type(prop, "RigidBodyConstraint");
|
2018-06-25 13:50:11 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Rigid Body Constraint", "Constraint constraining rigid bodies");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-10 16:01:38 +02:00
|
|
|
prop = RNA_def_property(srna, "use_simulation_cache", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "flag", OB_FLAG_USE_SIMULATION_CACHE);
|
2023-05-10 16:01:38 +02:00
|
|
|
RNA_def_property_ui_text(
|
2023-07-10 16:02:31 +02:00
|
|
|
prop, "Use Simulation Cache", "Cache frames during simulation nodes playback");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2023-05-10 16:01:38 +02:00
|
|
|
|
2021-08-04 17:46:55 +02:00
|
|
|
rna_def_object_visibility(srna);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 20:01:03 +01:00
|
|
|
/* instancing */
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "instance_type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_bitflag_sdna(prop, nullptr, "transflag");
|
2018-11-28 17:49:52 +01:00
|
|
|
RNA_def_property_enum_items(prop, instance_items);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_funcs(prop, nullptr, nullptr, "rna_Object_instance_type_itemf");
|
2018-11-28 20:01:03 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Instance Type", "If not None, object instancing method to use");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "use_instance_vertices_rotation", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLIROT);
|
2019-03-06 16:43:37 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Orient with Normals", "Rotate instance according to vertex normal");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "use_instance_faces_scale", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLIFACES_SCALE);
|
2019-03-06 16:43:37 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Scale to Face Sizes", "Scale instance based on face size");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "instance_faces_scale", PROP_FLOAT, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_float_sdna(prop, nullptr, "instance_faces_scale");
|
2009-02-02 11:51:10 +00:00
|
|
|
RNA_def_property_range(prop, 0.001f, 10000.0f);
|
2018-11-28 20:01:03 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Instance Faces Scale", "Scale the face instance objects");
|
2014-09-24 19:48:16 +02:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "instance_collection", PROP_POINTER, PROP_NONE);
|
Collections and groups unification
OVERVIEW
* In 2.7 terminology, all layers and groups are now collection datablocks.
* These collections are nestable, linkable, instanceable, overrideable, ..
which opens up new ways to set up scenes and link + override data.
* Viewport/render visibility and selectability are now a part of the collection
and shared across all view layers and linkable.
* View layers define which subset of the scene collection hierarchy is excluded
for each. For many workflows one view layer can be used, these are more of an
advanced feature now.
OUTLINER
* The outliner now has a "View Layer" display mode instead of "Collections",
which can display the collections and/or objects in the view layer.
* In this display mode, collections can be excluded with the right click menu.
These will then be greyed out and their objects will be excluded.
* To view collections not linked to any scene, the "Blender File" display mode
can be used, with the new filtering option to just see Colleciton datablocks.
* The outliner right click menus for collections and objects were reorganized.
* Drag and drop still needs to be improved. Like before, dragging the icon or
text gives different results, we'll unify this later.
LINKING AND OVERRIDES
* Collections can now be linked into the scene without creating an instance,
with the link/append operator or from the collections view in the outliner.
* Collections can get static overrides with the right click menu in the outliner,
but this is rather unreliable and not clearly communicated at the moment.
* We still need to improve the make override operator to turn collection instances
into collections with overrides directly in the scene.
PERFORMANCE
* We tried to make performance not worse than before and improve it in some
cases. The main thing that's still a bit slower is multiple scenes, we have to
change the layer syncing to only updated affected scenes.
* Collections keep a list of their parent collections for faster incremental
updates in syncing and caching.
* View layer bases are now in a object -> base hash to avoid quadratic time
lookups internally and in API functions like visible_get().
VERSIONING
* Compatibility with 2.7 files should be improved due to the new visibility
controls. Of course users may not want to set up their scenes differently
now to avoid having separate layers and groups.
* Compatibility with 2.8 is mostly there, and was tested on Eevee demo and Hero
files. There's a few things which are know to be not quite compatible, like
nested layer collections inside groups.
* The versioning code for 2.8 files is quite complicated, and isolated behind
#ifdef so it can be removed at the end of the release cycle.
KNOWN ISSUES
* The G-key group operators in the 3D viewport were left mostly as is, they
need to be modified still to fit better.
* Same for the groups panel in the object properties. This needs to be updated
still, or perhaps replaced by something better.
* Collections must all have a unique name. Less restrictive namespacing is to
be done later, we'll have to see how important this is as all objects within
the collections must also have a unique name anyway.
* Full scene copy and delete scene are exactly doing the right thing yet.
Differential Revision: https://developer.blender.org/D3383
https://code.blender.org/2018/05/collections-and-groups/
2018-04-30 15:57:22 +02:00
|
|
|
RNA_def_property_struct_type(prop, "Collection");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "instance_collection");
|
2009-05-28 23:23:47 +00:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, nullptr, "rna_Object_dup_collection_set", nullptr, nullptr);
|
2018-11-28 17:49:52 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Instance Collection", "Instance an existing collection");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "is_instancer", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "transflag", OB_DUPLI);
|
2010-05-02 13:48:32 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-02 16:58:09 +00:00
|
|
|
/* drawing */
|
2018-09-03 18:58:41 +02:00
|
|
|
prop = RNA_def_property(srna, "display_type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "dt");
|
2009-01-02 16:58:09 +00:00
|
|
|
RNA_def_property_enum_items(prop, drawtype_items);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display As", "How to display object in viewport");
|
2014-03-13 02:50:01 +09:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_internal_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_bounds", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWBOUNDOX);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Bounds", "Display the object's bounds");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-03 18:58:41 +02:00
|
|
|
prop = RNA_def_property(srna, "display_bounds_type", PROP_ENUM, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_enum_sdna(prop, nullptr, "boundtype");
|
2009-01-02 16:58:09 +00:00
|
|
|
RNA_def_property_enum_items(prop, boundtype_items);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Bounds Type", "Object boundary display type");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWNAME);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Name", "Display the object's name");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_axis", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_AXIS);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Axes", "Display the object's origin and axes");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_texture_space", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_TEXSPACE);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display Texture Space", "Display the object's texture space");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_wire", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWWIRE);
|
2021-03-03 12:14:06 +01:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Display Wire", "Display the object's wireframe over solid shading");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-18 19:01:26 +00:00
|
|
|
prop = RNA_def_property(srna, "show_all_edges", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAW_ALL_EDGES);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Display All Edges", "Display all edges for mesh objects");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-09 16:27:24 +01:00
|
|
|
prop = RNA_def_property(srna, "use_grease_pencil_lights", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_USE_GPENCIL_LIGHTS);
|
2020-03-09 16:27:24 +01:00
|
|
|
RNA_def_property_boolean_default(prop, true);
|
2024-10-15 13:00:47 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Use Lights", "Lights affect Grease Pencil object");
|
2025-02-25 10:46:27 +01:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_grease_pencil_update");
|
2020-03-09 16:27:24 +01:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAWTRANSP);
|
2018-09-03 18:58:41 +02:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Display Transparent", "Display material transparency in the object");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-03 18:58:41 +02:00
|
|
|
prop = RNA_def_property(srna, "show_in_front", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "dtx", OB_DRAW_IN_FRONT);
|
UI: Clean up labels and descriptions: "Draw" to "Display"
In Blender, we used to use the term 'draw' to refer to information
displayed to the user. For version 2.80, it was decided to change these
instances to 'display' instead. This was to avoid the ambiguity between
end-user drawing tools and display options.
From the Oxford English Dictionary:
- Draw: produce (a picture or diagram) by making lines and marks on
paper with a pencil, pen, etc.
- Display: show (data or an image) on a computer, television, or
other screen.
Therefore, we should use draw when referring to drawing tools for
making marks, but use display when referring to information
shown/displayed to the user. From a user POV, the computer displays
certain information, whereas the user draws a mark.
Apparently this change was not implemented consistently, so this patch
changes all remaining relevant instances of "draw".
Differential Revision: https://developer.blender.org/D10551
2021-03-02 11:58:25 -06:00
|
|
|
RNA_def_property_ui_text(prop, "In Front", "Make the object display in front of others");
|
2025-02-25 10:46:27 +01:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_grease_pencil_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-02 11:51:10 +00:00
|
|
|
/* pose */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "pose", PROP_POINTER, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_sdna(prop, nullptr, "pose");
|
2009-01-07 04:06:52 +00:00
|
|
|
RNA_def_property_struct_type(prop, "Pose");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Pose", "Current pose for armatures");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-02 16:58:09 +00:00
|
|
|
/* shape keys */
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "shapeflag", OB_SHAPE_LOCK);
|
2025-01-27 13:13:46 -05:00
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop, "Solo Active Shape Key", "Only show the active shape key at full value");
|
2025-01-27 17:44:26 +01:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_SOLO_OFF, 1);
|
2010-06-09 08:24:31 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "use_shape_key_edit_mode", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "shapeflag", OB_SHAPE_EDIT_MODE);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(
|
2023-05-22 17:15:38 -06:00
|
|
|
prop, "Shape Key Edit Mode", "Display shape keys in edit mode (for meshes only)");
|
2009-11-01 00:06:53 +00:00
|
|
|
RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
|
2010-06-09 08:24:31 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Object_internal_update_data");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE);
|
2009-07-03 15:23:33 +00:00
|
|
|
RNA_def_property_struct_type(prop, "ShapeKey");
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE | PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(
|
|
|
|
|
prop, "rna_Object_active_shape_key_get", nullptr, nullptr, nullptr);
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_int_sdna(prop, nullptr, "shapenr");
|
2012-03-05 23:30:41 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_property_int_funcs(prop,
|
|
|
|
|
"rna_Object_active_shape_key_index_get",
|
|
|
|
|
"rna_Object_active_shape_key_index_set",
|
|
|
|
|
"rna_Object_active_shape_key_index_range");
|
2010-02-10 21:15:44 +00:00
|
|
|
RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index");
|
2009-11-01 00:06:53 +00:00
|
|
|
RNA_def_property_update(prop, 0, "rna_Object_active_shape_update");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-12-30 18:27:33 +00:00
|
|
|
/* sculpt */
|
|
|
|
|
prop = RNA_def_property(srna, "use_dynamic_topology_sculpting", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_funcs(prop, "rna_Object_use_dynamic_topology_sculpting_get", nullptr);
|
2012-12-30 18:27:33 +00:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_ui_text(prop, "Dynamic Topology Sculpting", nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-24 11:24:37 -02:00
|
|
|
/* Base Settings */
|
2018-11-28 17:49:52 +01:00
|
|
|
prop = RNA_def_property(srna, "is_from_instancer", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "base_flag", BASE_FROM_DUPLI);
|
2018-11-28 20:01:03 +01:00
|
|
|
RNA_def_property_ui_text(prop, "Base from Instancer", "Object comes from a instancer");
|
2017-11-24 11:24:37 -02:00
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-24 11:24:37 -02:00
|
|
|
prop = RNA_def_property(srna, "is_from_set", PROP_BOOLEAN, PROP_NONE);
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_boolean_sdna(prop, nullptr, "base_flag", BASE_FROM_SET);
|
2017-11-24 11:24:37 -02:00
|
|
|
RNA_def_property_ui_text(prop, "Base from Set", "Object comes from a background set");
|
|
|
|
|
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON);
|
|
|
|
|
RNA_def_property_override_clear_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-09 15:13:12 +02:00
|
|
|
/* Object Display */
|
|
|
|
|
prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
|
2019-02-11 10:32:11 +11:00
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
2018-05-09 15:13:12 +02:00
|
|
|
RNA_def_property_struct_type(prop, "ObjectDisplay");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Object_display_get", nullptr, nullptr, nullptr);
|
2020-12-24 11:07:32 -06:00
|
|
|
RNA_def_property_ui_text(prop, "Object Display", "Object display settings for 3D viewport");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-16 19:35:53 +01:00
|
|
|
/* Line Art */
|
|
|
|
|
prop = RNA_def_property(srna, "lineart", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "ObjectLineArt");
|
2024-04-15 20:02:38 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Line Art", "Line Art settings for the object");
|
2021-03-16 19:35:53 +01:00
|
|
|
|
2021-04-02 14:44:26 +02:00
|
|
|
/* Mesh Symmetry Settings */
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_mesh_mirror_x", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(
|
|
|
|
|
prop, "rna_Object_mesh_symmetry_x_get", "rna_Object_mesh_symmetry_x_set");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "X", "Enable mesh symmetry in the X axis");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2021-04-02 14:44:26 +02:00
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_mesh_mirror_y", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(
|
|
|
|
|
prop, "rna_Object_mesh_symmetry_y_get", "rna_Object_mesh_symmetry_y_set");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Y", "Enable mesh symmetry in the Y axis");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2021-04-02 14:44:26 +02:00
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "use_mesh_mirror_z", PROP_BOOLEAN, PROP_NONE);
|
|
|
|
|
RNA_def_property_boolean_funcs(
|
|
|
|
|
prop, "rna_Object_mesh_symmetry_z_get", "rna_Object_mesh_symmetry_z_set");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_editable_func(prop, "rna_Object_mesh_symmetry_yz_editable");
|
|
|
|
|
RNA_def_property_ui_text(prop, "Z", "Enable mesh symmetry in the Z axis");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
2021-04-02 14:44:26 +02:00
|
|
|
|
2022-04-02 00:11:11 +02:00
|
|
|
/* Lightgroup Membership */
|
|
|
|
|
prop = RNA_def_property(srna, "lightgroup", PROP_STRING, PROP_NONE);
|
|
|
|
|
RNA_def_property_string_funcs(prop,
|
|
|
|
|
"rna_Object_lightgroup_get",
|
|
|
|
|
"rna_Object_lightgroup_length",
|
|
|
|
|
"rna_Object_lightgroup_set");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Lightgroup", "Lightgroup that the object belongs to");
|
|
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
/* Light Linking. */
|
|
|
|
|
prop = RNA_def_property(srna, "light_linking", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_flag(prop, PROP_NEVER_NULL);
|
|
|
|
|
RNA_def_property_struct_type(prop, "ObjectLightLinking");
|
2023-06-14 14:55:44 -04:00
|
|
|
RNA_def_property_pointer_funcs(prop, "rna_Object_light_linking_get", nullptr, nullptr, nullptr);
|
2025-10-01 18:11:19 +02:00
|
|
|
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
|
|
|
|
RNA_def_property_override_funcs(
|
|
|
|
|
prop, nullptr, nullptr, "rna_Object_light_linking_override_apply");
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_property_ui_text(prop, "Light Linking", "Light linking settings");
|
|
|
|
|
|
2025-04-25 19:12:04 +02:00
|
|
|
/* Shadow terminator. */
|
|
|
|
|
prop = RNA_def_property(srna, "shadow_terminator_normal_offset", PROP_FLOAT, PROP_DISTANCE);
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
|
|
|
|
RNA_def_property_ui_range(prop, 0.0, 10, 0.01f, 4);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Shadow Terminator Normal Offset",
|
2025-05-19 22:12:17 +02:00
|
|
|
"Offset rays from the surface to reduce shadow terminator artifact on low poly geometry. "
|
2025-04-25 19:12:04 +02:00
|
|
|
"Only affect triangles that are affected by the geometry offset");
|
|
|
|
|
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "shadow_terminator_geometry_offset", PROP_FLOAT, PROP_FACTOR);
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
|
|
|
|
RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
|
|
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Shadow Terminator Geometry Offset",
|
|
|
|
|
"Offset rays from the surface to reduce shadow terminator artifact on "
|
|
|
|
|
"low poly geometry. Only affects triangles at grazing angles to light");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "shadow_terminator_shading_offset", PROP_FLOAT, PROP_FACTOR);
|
|
|
|
|
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
|
|
|
|
RNA_def_property_ui_range(prop, 0.0, 1.0, 1, 2);
|
|
|
|
|
RNA_def_property_ui_text(
|
|
|
|
|
prop,
|
|
|
|
|
"Shadow Terminator Shading Offset",
|
|
|
|
|
"Push the shadow terminator towards the light to hide artifacts on low poly geometry");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, nullptr);
|
|
|
|
|
|
2020-06-30 16:06:08 +02:00
|
|
|
RNA_define_lib_overridable(false);
|
|
|
|
|
|
|
|
|
|
/* anim */
|
|
|
|
|
rna_def_animdata_common(srna);
|
|
|
|
|
|
|
|
|
|
rna_def_animviz_common(srna);
|
|
|
|
|
rna_def_motionpath_common(srna);
|
|
|
|
|
|
2009-06-18 19:48:55 +00:00
|
|
|
RNA_api_object(srna);
|
2009-01-01 20:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
static void rna_def_object_light_linking(BlenderRNA *brna)
|
|
|
|
|
{
|
|
|
|
|
StructRNA *srna;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
2023-06-14 14:55:44 -04:00
|
|
|
srna = RNA_def_struct(brna, "ObjectLightLinking", nullptr);
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_struct_ui_text(srna, "Object Light Linking", "");
|
|
|
|
|
RNA_def_struct_sdna(srna, "Object");
|
|
|
|
|
RNA_def_struct_nested(brna, srna, "Object");
|
|
|
|
|
RNA_def_struct_path_func(srna, "rna_ObjectLightLinking_path");
|
|
|
|
|
|
2025-10-01 18:11:19 +02:00
|
|
|
RNA_define_lib_overridable(true);
|
|
|
|
|
|
2023-05-24 13:36:13 +02:00
|
|
|
prop = RNA_def_property(srna, "receiver_collection", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "Collection");
|
2025-08-08 12:02:08 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_LightLinking_receiver_collection_get",
|
|
|
|
|
"rna_LightLinking_receiver_collection_set",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Receiver Collection",
|
|
|
|
|
"Collection which defines light linking relation of this emitter");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_LightLinking_collection_update");
|
|
|
|
|
|
|
|
|
|
prop = RNA_def_property(srna, "blocker_collection", PROP_POINTER, PROP_NONE);
|
|
|
|
|
RNA_def_property_struct_type(prop, "Collection");
|
2025-08-08 12:02:08 +02:00
|
|
|
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_property_pointer_funcs(prop,
|
|
|
|
|
"rna_LightLinking_blocker_collection_get",
|
|
|
|
|
"rna_LightLinking_blocker_collection_set",
|
2023-06-14 14:55:44 -04:00
|
|
|
nullptr,
|
|
|
|
|
nullptr);
|
2023-05-24 13:36:13 +02:00
|
|
|
RNA_def_property_ui_text(prop,
|
|
|
|
|
"Blocker Collection",
|
|
|
|
|
"Collection which defines objects which block light from this emitter");
|
|
|
|
|
RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_LightLinking_collection_update");
|
2025-10-01 18:11:19 +02:00
|
|
|
|
|
|
|
|
RNA_define_lib_overridable(false);
|
2023-05-24 13:36:13 +02:00
|
|
|
}
|
|
|
|
|
|
2009-01-01 20:44:40 +00:00
|
|
|
void RNA_def_object(BlenderRNA *brna)
|
|
|
|
|
{
|
2009-01-10 22:57:33 +00:00
|
|
|
rna_def_object(brna);
|
2013-10-01 04:49:47 +00:00
|
|
|
|
|
|
|
|
RNA_define_animate_sdna(false);
|
2009-01-02 13:47:33 +00:00
|
|
|
rna_def_vertex_group(brna);
|
2009-06-03 23:22:43 +00:00
|
|
|
rna_def_material_slot(brna);
|
2018-05-09 15:13:12 +02:00
|
|
|
rna_def_object_display(brna);
|
2021-03-16 19:35:53 +01:00
|
|
|
rna_def_object_lineart(brna);
|
2023-05-24 13:36:13 +02:00
|
|
|
rna_def_object_light_linking(brna);
|
2013-10-01 04:49:47 +00:00
|
|
|
RNA_define_animate_sdna(true);
|
2008-10-31 23:50:02 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#endif
|