Blender V5.0
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
5#include "WM_api.hh"
6
7#include "BLI_listbase.h"
8
9#include "BKE_context.hh"
10#include "BKE_global.hh"
11#include "BKE_main.hh"
12
13#include "DEG_depsgraph.hh"
14
15#include "RNA_access.hh"
16#include "RNA_define.hh"
17
18#include "geometry_intern.hh"
19
20namespace blender::ed::geometry {
21
23 wmOperator *op,
24 const wmEvent *event)
25{
26 RNA_boolean_set(op->ptr, "value", G.randomize_geometry_element_order);
27 return WM_operator_props_popup(C, op, event);
28}
29
31{
32 Main *bmain = CTX_data_main(C);
33
34 G.randomize_geometry_element_order = RNA_boolean_get(op->ptr, "value");
35
36 LISTBASE_FOREACH (Object *, object, &bmain->objects) {
38 }
40 return OPERATOR_FINISHED;
41}
42
44{
45 ot->name = "Set Geometry Randomization";
46 ot->idname = "GEOMETRY_OT_geometry_randomization";
47 ot->description = "Toggle geometry randomization for debugging purposes";
48
52
53 RNA_def_boolean(ot->srna,
54 "value",
55 false,
56 "Value",
57 "Randomize the order of geometry elements (e.g. vertices or edges) after some "
58 "operations where there are no guarantees about the order. This avoids "
59 "accidentally depending on something that may change in the future");
60}
61
62} // namespace blender::ed::geometry
Main * CTX_data_main(const bContext *C)
#define LISTBASE_FOREACH(type, var, list)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ OPERATOR_FINISHED
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:375
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
#define G(x, y, z)
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)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ListBase objects
Definition BKE_main.hh:280
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4237
wmOperatorStatus WM_operator_props_popup(bContext *C, wmOperator *op, const wmEvent *)