Blender V5.3
geometry_randomization.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "WM_api.hh"
10
11#include "BLI_listbase.hh"
12
13#include "BKE_context.hh"
14#include "BKE_global.hh"
15#include "BKE_main.hh"
16
17#include "DEG_depsgraph.hh"
18
19#include "RNA_access.hh"
20#include "RNA_define.hh"
21
22#include "geometry_intern.hh"
23
24namespace blender::ed::geometry {
25
27 wmOperator *op,
28 const wmEvent *event)
29{
30 RNA_boolean_set(op->ptr, "value", G.randomize_geometry_element_order);
31 return WM_operator_props_popup(C, op, event);
32}
33
35{
36 Main *bmain = CTX_data_main(C);
37
38 G.randomize_geometry_element_order = RNA_boolean_get(op->ptr, "value");
39
40 for (Object &object : bmain->objects) {
42 }
44 return OPERATOR_FINISHED;
45}
46
48{
49 ot->name = "Set Geometry Randomization";
50 ot->idname = "GEOMETRY_OT_geometry_randomization";
51 ot->description = "Toggle geometry randomization for debugging purposes";
52
56
58 "value",
59 false,
60 "Value",
61 "Randomize the order of geometry elements (e.g. vertices or edges) after some "
62 "operations where there are no guarantees about the order. This avoids "
63 "accidentally depending on something that may change in the future");
64}
65
66} // namespace blender::ed::geometry
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:388
static wmOperatorStatus geometry_randomization_exec(bContext *C, wmOperator *op)
static wmOperatorStatus geometry_randomization_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void GEOMETRY_OT_geometry_randomization(wmOperatorType *ot)
Global G
Definition blender.cc:57
void DEG_id_tag_update(ID *id, unsigned int flags)
wmOperatorStatus WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
Main * CTX_data_main(const bContext *C)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ListBaseT< Object > objects
Definition BKE_main.hh:388
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141