Blender V4.3
orientation.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 "BKE_main.hh"
6#include "DNA_scene_types.h"
7#include "RNA_access.hh"
8#include "RNA_types.hh"
9
10#include "IO_orientation.hh"
11
13 {IO_AXIS_X, "X", 0, "X", "Positive X axis"},
14 {IO_AXIS_Y, "Y", 0, "Y", "Positive Y axis"},
15 {IO_AXIS_Z, "Z", 0, "Z", "Positive Z axis"},
16 {IO_AXIS_NEGATIVE_X, "NEGATIVE_X", 0, "-X", "Negative X axis"},
17 {IO_AXIS_NEGATIVE_Y, "NEGATIVE_Y", 0, "-Y", "Negative Y axis"},
18 {IO_AXIS_NEGATIVE_Z, "NEGATIVE_Z", 0, "-Z", "Negative Z axis"},
19 {0, nullptr, 0, nullptr, nullptr}};
20
21void io_ui_forward_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
22{
23 /* Both forward and up axes cannot be along the same direction. */
24
25 int forward = RNA_enum_get(ptr, "forward_axis");
26 int up = RNA_enum_get(ptr, "up_axis");
27 if ((forward % 3) == (up % 3)) {
28 RNA_enum_set(ptr, "up_axis", (up + 1) % 6);
29 }
30}
31
32void io_ui_up_axis_update(Main * /*main*/, Scene * /*scene*/, PointerRNA *ptr)
33{
34 int forward = RNA_enum_get(ptr, "forward_axis");
35 int up = RNA_enum_get(ptr, "up_axis");
36 if ((forward % 3) == (up % 3)) {
37 RNA_enum_set(ptr, "forward_axis", (forward + 1) % 6);
38 }
39}
@ IO_AXIS_Y
@ IO_AXIS_NEGATIVE_Z
@ IO_AXIS_NEGATIVE_X
@ IO_AXIS_Z
@ IO_AXIS_NEGATIVE_Y
@ IO_AXIS_X
const EnumPropertyItem io_transform_axis[]
void io_ui_forward_axis_update(Main *, Scene *, PointerRNA *ptr)
void io_ui_up_axis_update(Main *, Scene *, PointerRNA *ptr)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PointerRNA * ptr
Definition wm_files.cc:4126