Blender V4.5
draw_handle.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
21
22#include "draw_shader_shared.hh"
23
24struct Object;
25struct DupliObject;
27
28namespace blender::draw {
29
31 /* Index for getting a specific resource in the resource arrays (e.g. object matrices).
32 * Last bit contains handedness. */
33 uint32_t raw;
34
35 ResourceHandle() = default;
36 ResourceHandle(uint raw_) : raw(raw_){};
37 ResourceHandle(uint index, bool inverted_handedness)
38 {
39 raw = index;
40 SET_FLAG_FROM_TEST(raw, inverted_handedness, 0x80000000u);
41 }
42
44 {
45 return (raw & 0x80000000u) != 0;
46 }
47
49 {
50 return (raw & 0x7FFFFFFFu);
51 }
52};
53
54/* Refers to a range of contiguous handles in the resource arrays.
55 * Typically used to render instances of an object, but can represent a single instance too.
56 * The associated objects will all share handedness and state and can be rendered together. */
58 /* First handle in the range. */
60 /* Number of handle in the range. */
61 uint32_t count;
62
66
68 {
69 return {handle_first.raw, count};
70 }
71
72 /* TODO(fclem): Temporary workaround to keep existing code to work. Should be removed once we
73 * complete the instance optimization project. */
74 operator ResourceHandle() const
75 {
76 return handle_first;
77 }
78};
79
80/* TODO(fclem): Move to somewhere more appropriated after cleaning up the header dependencies. */
81struct ObjectRef {
89
90 ObjectRef() = default;
91 ObjectRef(DEGObjectIterData &iter_data, Object *ob);
92 explicit ObjectRef(Object *ob);
93
94 /* Is the object coming from a Dupli system. */
95 bool is_dupli() const
96 {
97 return dupli_object != nullptr;
98 }
99};
100
101}; // namespace blender::draw
unsigned int uint
#define SET_FLAG_FROM_TEST(value, test, flag)
DupliObject * dupli_object
ResourceHandleRange handle
ResourceHandleRange(ResourceHandle handle, uint len)
ResourceHandleRange(ResourceHandle handle)
ResourceHandle(uint index, bool inverted_handedness)
uint len