Blender V4.3
obj_import_objects.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include "BLI_map.hh"
12#include "BLI_math_base.hh"
14#include "BLI_set.hh"
15#include "BLI_vector.hh"
16
17#include "DNA_object_types.h"
18
19namespace blender::io::obj {
20
28
39
40 void set_vertex_color(size_t index, float3 color)
41 {
42 if (index >= vertex_colors.size()) {
43 vertex_colors.resize(index + 1, float3(-1.0, -1.0, -1.0));
44 }
45 vertex_colors[index] = color;
46 }
47
48 bool has_vertex_color(size_t index) const
49 {
50 return index < vertex_colors.size() && vertex_colors[index].x >= 0.0;
51 }
52
54 {
55 if (!mrgb_block.is_empty()) {
56 /* Set color of the last mrgb_block.size() verts. */
57 size_t start_of_block = 0;
58 if (mrgb_block.size() <= vertices.size()) {
59 start_of_block = vertices.size() - mrgb_block.size();
60 }
61 if (start_of_block == 0) {
62 vertex_colors = std::move(mrgb_block);
63 }
64 else {
65 vertex_colors.resize(start_of_block, float3(-1.0, -1.0, -1.0));
67 }
68 mrgb_block.clear();
69 }
70 }
71};
72
76struct FaceCorner {
77 /* These indices range from zero to total vertices in the OBJ file. */
79 /* -1 is to indicate absence of UV vertices. Only < 0 condition should be checked since
80 * it can be less than -1 too. */
81 int uv_vert_index = -1;
83};
84
85struct FaceElem {
88 bool shaded_smooth = false;
89 int start_index_ = 0;
91};
92
101 std::string group_;
102 int degree = 0;
103 float2 range{0.0f, 1.0f};
108 /* Values in the parm u/v line in a curve definition. */
110};
111
116
117struct Geometry {
119 std::string geometry_name_;
124
125 int vertex_index_min_ = INT_MAX;
127 /* Global vertex indices used by this geometry. */
129 /* Mapping from global vertex index to geometry-local vertex index. */
131 /* Loose edges in the file. */
133
136
137 bool has_invalid_faces_ = false;
138 bool has_vertex_groups_ = false;
141
143 {
144 return int(vertices_.size());
145 }
146 void track_vertex_index(int index)
147 {
148 vertices_.add(index);
151 }
153 {
155 for (int i = 0; i < count; ++i) {
156 vertices_.add(i);
157 }
160 }
161};
162
163} // namespace blender::io::obj
Object is a sort of wrapper for general info.
@ OB_MESH
@ OB_CURVES_LEGACY
int64_t size() const
Definition BLI_set.hh:564
void reserve(const int64_t n)
Definition BLI_set.hh:614
bool add(const Key &key)
Definition BLI_set.hh:248
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
int count
void min_inplace(T &a, const T &b)
void max_inplace(T &a, const T &b)
VecBase< float, 3 > float3
Vector< std::string > material_order_
Map< int, int > global_to_local_vertices_
Vector< FaceCorner > face_corners_
Map< std::string, int > group_indices_
Vector< std::string > group_order_
Map< std::string, int > material_indices_
bool has_vertex_color(size_t index) const
void set_vertex_color(size_t index, float3 color)