Skip to content

Commit bc74b4c

Browse files
committed
Rename face normals to boundary normals
1 parent 17d4aeb commit bc74b4c

File tree

6 files changed

+63
-63
lines changed

6 files changed

+63
-63
lines changed

addons/nd/doc_classes/ArrayCellMeshND.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
<member name="dimension" type="int" setter="set_dimension" getter="get_dimension" default="0">
3131
The dimension of the mesh. This is calculated as the length of the first vertex. Setting this will resize all vertices to the new dimension, either truncating them or padding them with zeros as necessary. The amount of indices making up a simplex cell is equal to the dimension.
3232
</member>
33-
<member name="simplex_cell_face_normals" type="PackedFloat64Array[]" setter="set_simplex_cell_face_normals" getter="get_simplex_cell_face_normals" default="[]">
34-
The normals of the simplex cells. Face normals define which side of the cell is the front side, and therefore should be drawn. Face normals can also be used to calculate vertex normals to determine how lighting angles are calculated for the cell. Each VectorN ([PackedFloat64Array]) in this array is for one cell, and should be normalized. This array should either be one-Nth as long as the [member cell_indices] array, or empty for no normals, or else the mesh is invalid.
33+
<member name="simplex_cell_boundary_normals" type="PackedFloat64Array[]" setter="set_simplex_cell_boundary_normals" getter="get_simplex_cell_boundary_normals" default="[]">
34+
The boundary normals of the simplex cells. Boundary normals define which side of the cell is the front side, and therefore should be drawn. Boundary normals can also be used to calculate vertex normals to determine how lighting angles are calculated for the cell. Each VectorN ([PackedFloat64Array]) in this array is for one cell, and should be normalized. This array should either be one-Nth as long as the [member cell_indices] array, or empty for no normals, or else the mesh is invalid.
3535
</member>
3636
<member name="simplex_cell_indices" type="PackedInt32Array" setter="set_simplex_cell_indices" getter="get_simplex_cell_indices" default="PackedInt32Array()">
3737
The indices of the cell cells. Every 4 integers defines a cell cell. Each integer is an index to the [member vertices] array. Integers in this array should not exceed the length of the vertices array, or else the mesh is invalid.

addons/nd/doc_classes/CellMeshND.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
<tutorials>
1111
</tutorials>
1212
<methods>
13-
<method name="_get_simplex_cell_face_normals" qualifiers="virtual">
13+
<method name="_get_simplex_cell_boundary_normals" qualifiers="virtual">
1414
<return type="PackedFloat64Array[]" />
1515
<description>
16-
Callback method that should return the face normals of the simplex cells. Do not call this method. This can be overridden by derived classes when creating a custom mesh type in GDScript or another scripting language. See [method get_cell_face_normals] for details of the returned data.
16+
Callback method that should return the boundary normals of the simplex cells. Do not call this method. This can be overridden by derived classes when creating a custom mesh type in GDScript or another scripting language. See [method get_cell_boundary_normals] for details of the returned data.
1717
</description>
1818
</method>
1919
<method name="_get_simplex_cell_indices" qualifiers="virtual">
@@ -49,16 +49,16 @@
4949
Gets the number of indices per cell. This is the number of vertices that make up a cell. For example, a triangle has 3 vertices, so the number of indices per cell is 3. The total number of indices in the [method get_cell_indices] array is equal to this value multiplied by [method get_cell_count].
5050
</description>
5151
</method>
52-
<method name="get_simplex_cell_count">
53-
<return type="int" />
52+
<method name="get_simplex_cell_boundary_normals">
53+
<return type="PackedFloat64Array[]" />
5454
<description>
55-
Gets the number of simplex cells in the cell mesh. Each simplex cell has [method get_indices_per_cell] vertex indices. Multiplying these together gives the length of the [method get_cell_indices] array.
55+
Gets the boundary normals of the simplex cells. Normals define which side of the cell is the front side, and therefore should be drawn. Boundary normals can also be used to calculate vertex normals to determine how lighting angles are calculated for the cell. Each VectorN ([PackedFloat64Array]) in this array is for one cell, and should be normalized. This array should either be one-fourth as long as the [method get_cell_indices] array, or empty for no normals, or else the mesh is invalid.
5656
</description>
5757
</method>
58-
<method name="get_simplex_cell_face_normals">
59-
<return type="PackedFloat64Array[]" />
58+
<method name="get_simplex_cell_count">
59+
<return type="int" />
6060
<description>
61-
Gets the face normals of the simplex cells. Normals define which side of the cell is the front side, and therefore should be drawn. Face normals can also be used to calculate vertex normals to determine how lighting angles are calculated for the cell. Each VectorN ([PackedFloat64Array]) in this array is for one cell, and should be normalized. This array should either be one-fourth as long as the [method get_cell_indices] array, or empty for no normals, or else the mesh is invalid.
61+
Gets the number of simplex cells in the cell mesh. Each simplex cell has [method get_indices_per_cell] vertex indices. Multiplying these together gives the length of the [method get_cell_indices] array.
6262
</description>
6363
</method>
6464
<method name="get_simplex_cell_indices">

model/mesh/cell/array_cell_mesh_nd.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ bool ArrayCellMeshND::validate_mesh_data() {
1313
if (cell_indices_count % dimension != 0) {
1414
return false; // Must be a multiple of _dimension.
1515
}
16-
const int64_t cell_face_normals_count = _simplex_cell_face_normals.size();
17-
if (cell_face_normals_count > 0 && cell_face_normals_count * dimension != cell_indices_count) {
16+
const int64_t cell_boundary_normals_count = _simplex_cell_boundary_normals.size();
17+
if (cell_boundary_normals_count > 0 && cell_boundary_normals_count * dimension != cell_indices_count) {
1818
return false; // Must have one normal per cell (dimension indices).
1919
}
2020
const int64_t cell_vertex_normals_count = _simplex_cell_vertex_normals.size();
@@ -55,11 +55,11 @@ PackedInt32Array ArrayCellMeshND::append_vertices(const Vector<VectorN> &p_verti
5555

5656
void ArrayCellMeshND::merge_with(const Ref<ArrayCellMeshND> &p_other, const Ref<TransformND> &p_transform) {
5757
const int64_t start_cell_index_count = _simplex_cell_indices.size();
58-
const int64_t start_cell_face_normal_count = _simplex_cell_face_normals.size();
58+
const int64_t start_cell_face_normal_count = _simplex_cell_boundary_normals.size();
5959
const int64_t start_cell_vertex_normal_count = _simplex_cell_vertex_normals.size();
6060
const int64_t start_vertex_count = _vertices.size();
6161
const int64_t other_cell_index_count = p_other->_simplex_cell_indices.size();
62-
const int64_t other_cell_face_normal_count = p_other->_simplex_cell_face_normals.size();
62+
const int64_t other_cell_face_normal_count = p_other->_simplex_cell_boundary_normals.size();
6363
const int64_t other_cell_vertex_normal_count = p_other->_simplex_cell_vertex_normals.size();
6464
const int64_t other_vertex_count = p_other->_vertices.size();
6565
const int64_t end_cell_index_count = start_cell_index_count + other_cell_index_count;
@@ -77,23 +77,23 @@ void ArrayCellMeshND::merge_with(const Ref<ArrayCellMeshND> &p_other, const Ref<
7777
// Can't simply add these together in case the first mesh has no normals.
7878
if (start_cell_face_normal_count > 0 || other_cell_face_normal_count > 0) {
7979
const int64_t end_cell_normal_count = end_cell_index_count / dimension;
80-
_simplex_cell_face_normals.resize(end_cell_normal_count);
80+
_simplex_cell_boundary_normals.resize(end_cell_normal_count);
8181
const int64_t start_normal_count = start_cell_index_count / dimension;
8282
// Initialize the mesh's face normals to zero if it has none.
8383
if (start_cell_face_normal_count == 0) {
8484
for (int64_t i = 0; i < start_normal_count; i++) {
85-
_simplex_cell_face_normals.set(i, VectorN());
85+
_simplex_cell_boundary_normals.set(i, VectorN());
8686
}
8787
}
8888
if (other_cell_face_normal_count == 0) {
8989
for (int64_t i = 0; i < other_cell_index_count / dimension; i++) {
90-
_simplex_cell_face_normals.set(start_normal_count + i, VectorN());
90+
_simplex_cell_boundary_normals.set(start_normal_count + i, VectorN());
9191
}
9292
}
9393
// Copy in the face normals from the other mesh.
9494
if (other_cell_face_normal_count > 0) {
9595
for (int64_t i = 0; i < other_cell_face_normal_count; i++) {
96-
_simplex_cell_face_normals.set(start_normal_count + i, p_transform->xform_basis(p_other->_simplex_cell_face_normals[i]));
96+
_simplex_cell_boundary_normals.set(start_normal_count + i, p_transform->xform_basis(p_other->_simplex_cell_boundary_normals[i]));
9797
}
9898
}
9999
}
@@ -132,20 +132,20 @@ void ArrayCellMeshND::set_simplex_cell_indices(const PackedInt32Array &p_simplex
132132
reset_mesh_data_validation();
133133
}
134134

135-
Vector<VectorN> ArrayCellMeshND::get_simplex_cell_face_normals() {
136-
return _simplex_cell_face_normals;
135+
Vector<VectorN> ArrayCellMeshND::get_simplex_cell_boundary_normals() {
136+
return _simplex_cell_boundary_normals;
137137
}
138138

139-
void ArrayCellMeshND::set_cell_face_normals(const Vector<VectorN> &p_simplex_cell_normals) {
140-
_simplex_cell_face_normals = p_simplex_cell_normals;
139+
void ArrayCellMeshND::set_cell_boundary_normals(const Vector<VectorN> &p_simplex_cell_normals) {
140+
_simplex_cell_boundary_normals = p_simplex_cell_normals;
141141
reset_mesh_data_validation();
142142
}
143143

144-
void ArrayCellMeshND::set_simplex_cell_face_normals_bind(const TypedArray<VectorN> &p_simplex_cell_face_normals) {
145-
_simplex_cell_face_normals.clear();
146-
_simplex_cell_face_normals.resize(p_simplex_cell_face_normals.size());
147-
for (int i = 0; i < p_simplex_cell_face_normals.size(); i++) {
148-
_simplex_cell_face_normals.set(i, p_simplex_cell_face_normals[i]);
144+
void ArrayCellMeshND::set_simplex_cell_boundary_normals_bind(const TypedArray<VectorN> &p_simplex_cell_boundary_normals) {
145+
_simplex_cell_boundary_normals.clear();
146+
_simplex_cell_boundary_normals.resize(p_simplex_cell_boundary_normals.size());
147+
for (int i = 0; i < p_simplex_cell_boundary_normals.size(); i++) {
148+
_simplex_cell_boundary_normals.set(i, p_simplex_cell_boundary_normals[i]);
149149
}
150150
reset_mesh_data_validation();
151151
}
@@ -205,13 +205,13 @@ void ArrayCellMeshND::_bind_methods() {
205205

206206
// Only bind the setters here because the getters are already bound in CellMeshND.
207207
ClassDB::bind_method(D_METHOD("set_simplex_cell_indices", "simplex_cell_indices"), &ArrayCellMeshND::set_simplex_cell_indices);
208-
ClassDB::bind_method(D_METHOD("set_simplex_cell_face_normals", "simplex_cell_normals"), &ArrayCellMeshND::set_simplex_cell_face_normals_bind);
208+
ClassDB::bind_method(D_METHOD("set_simplex_cell_boundary_normals", "simplex_cell_normals"), &ArrayCellMeshND::set_simplex_cell_boundary_normals_bind);
209209
ClassDB::bind_method(D_METHOD("set_simplex_cell_vertex_normals", "simplex_cell_vertex_normals"), &ArrayCellMeshND::set_simplex_cell_vertex_normals_bind);
210210
ClassDB::bind_method(D_METHOD("set_vertices", "vertices"), &ArrayCellMeshND::set_vertices_bind);
211211
ClassDB::bind_method(D_METHOD("set_dimension", "dimension"), &ArrayCellMeshND::set_dimension);
212212

213213
ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "simplex_cell_indices"), "set_simplex_cell_indices", "get_simplex_cell_indices");
214-
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "simplex_cell_face_normals", PROPERTY_HINT_ARRAY_TYPE, "PackedFloat64Array"), "set_simplex_cell_face_normals", "get_simplex_cell_face_normals");
214+
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "simplex_cell_boundary_normals", PROPERTY_HINT_ARRAY_TYPE, "PackedFloat64Array"), "set_simplex_cell_boundary_normals", "get_simplex_cell_boundary_normals");
215215
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "simplex_cell_vertex_normals", PROPERTY_HINT_ARRAY_TYPE, "PackedFloat64Array"), "set_simplex_cell_vertex_normals", "get_simplex_cell_vertex_normals");
216216
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "vertices", PROPERTY_HINT_ARRAY_TYPE, "PackedFloat64Array"), "set_vertices", "get_vertices");
217217
ADD_PROPERTY(PropertyInfo(Variant::INT, "dimension", PROPERTY_HINT_RANGE, "0,1000,1", PROPERTY_USAGE_EDITOR), "set_dimension", "get_dimension");

model/mesh/cell/array_cell_mesh_nd.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ArrayCellMeshND : public CellMeshND {
77
GDCLASS(ArrayCellMeshND, CellMeshND);
88

99
PackedInt32Array _simplex_cell_indices;
10-
Vector<VectorN> _simplex_cell_face_normals;
10+
Vector<VectorN> _simplex_cell_boundary_normals;
1111
Vector<VectorN> _simplex_cell_vertex_normals;
1212
Vector<VectorN> _vertices;
1313

@@ -26,9 +26,9 @@ class ArrayCellMeshND : public CellMeshND {
2626
virtual PackedInt32Array get_simplex_cell_indices() override;
2727
void set_simplex_cell_indices(const PackedInt32Array &p_simplex_cell_indices);
2828

29-
virtual Vector<VectorN> get_simplex_cell_face_normals() override;
30-
void set_cell_face_normals(const Vector<VectorN> &p_simplex_cell_face_normals);
31-
void set_simplex_cell_face_normals_bind(const TypedArray<VectorN> &p_simplex_cell_face_normals);
29+
virtual Vector<VectorN> get_simplex_cell_boundary_normals() override;
30+
void set_cell_boundary_normals(const Vector<VectorN> &p_simplex_cell_boundary_normals);
31+
void set_simplex_cell_boundary_normals_bind(const TypedArray<VectorN> &p_simplex_cell_boundary_normals);
3232

3333
virtual Vector<VectorN> get_simplex_cell_vertex_normals() override;
3434
void set_simplex_cell_vertex_normals(const Vector<VectorN> &p_simplex_cell_vertex_normals);

model/mesh/cell/cell_mesh_nd.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Ref<ArrayCellMeshND> CellMeshND::to_array_cell_mesh() {
128128
array_mesh.instantiate();
129129
array_mesh->set_vertices(get_vertices());
130130
array_mesh->set_simplex_cell_indices(get_simplex_cell_indices());
131-
array_mesh->set_cell_face_normals(get_simplex_cell_face_normals());
131+
array_mesh->set_cell_boundary_normals(get_simplex_cell_boundary_normals());
132132
array_mesh->set_simplex_cell_vertex_normals(get_simplex_cell_vertex_normals());
133133
array_mesh->set_material(get_material());
134134
return array_mesh;
@@ -164,16 +164,16 @@ Vector<VectorN> CellMeshND::get_simplex_cell_positions() {
164164
return _cell_positions_cache;
165165
}
166166

167-
Vector<VectorN> CellMeshND::get_simplex_cell_face_normals() {
168-
TypedArray<VectorN> face_normals_bind;
169-
GDVIRTUAL_CALL(_get_simplex_cell_face_normals, face_normals_bind);
170-
Vector<VectorN> face_normals;
171-
face_normals.resize(face_normals_bind.size());
172-
for (int i = 0; i < face_normals_bind.size(); i++) {
173-
const VectorN &cell_face_normal = face_normals_bind[i];
174-
face_normals.set(i, cell_face_normal);
167+
Vector<VectorN> CellMeshND::get_simplex_cell_boundary_normals() {
168+
TypedArray<VectorN> boundary_normals_bind;
169+
GDVIRTUAL_CALL(_get_simplex_cell_boundary_normals, boundary_normals_bind);
170+
Vector<VectorN> boundary_normals;
171+
boundary_normals.resize(boundary_normals_bind.size());
172+
for (int i = 0; i < boundary_normals_bind.size(); i++) {
173+
const VectorN cell_face_normal = boundary_normals_bind[i];
174+
boundary_normals.set(i, cell_face_normal);
175175
}
176-
return face_normals;
176+
return boundary_normals;
177177
}
178178

179179
Vector<VectorN> CellMeshND::get_simplex_cell_vertex_normals() {
@@ -182,25 +182,25 @@ Vector<VectorN> CellMeshND::get_simplex_cell_vertex_normals() {
182182
Vector<VectorN> vertex_normals;
183183
vertex_normals.resize(vertex_normals_bind.size());
184184
for (int i = 0; i < vertex_normals_bind.size(); i++) {
185-
const VectorN &cell_vertex_normal = vertex_normals_bind[i];
185+
const VectorN cell_vertex_normal = vertex_normals_bind[i];
186186
vertex_normals.set(i, cell_vertex_normal);
187187
}
188188
return vertex_normals;
189189
}
190190

191-
TypedArray<VectorN> CellMeshND::get_simplex_cell_face_normals_bind() {
192-
TypedArray<VectorN> face_normals_bind;
193-
GDVIRTUAL_CALL(_get_simplex_cell_face_normals, face_normals_bind);
194-
if (!face_normals_bind.is_empty()) {
195-
return face_normals_bind;
191+
TypedArray<VectorN> CellMeshND::get_simplex_cell_boundary_normals_bind() {
192+
TypedArray<VectorN> boundary_normals_bind;
193+
GDVIRTUAL_CALL(_get_simplex_cell_boundary_normals, boundary_normals_bind);
194+
if (!boundary_normals_bind.is_empty()) {
195+
return boundary_normals_bind;
196196
}
197-
const Vector<VectorN> face_normals = get_simplex_cell_face_normals();
198-
face_normals_bind.resize(face_normals.size());
199-
for (int i = 0; i < face_normals.size(); i++) {
200-
const VectorN &cell_face_normal = face_normals[i];
201-
face_normals_bind[i] = cell_face_normal;
197+
const Vector<VectorN> boundary_normals = get_simplex_cell_boundary_normals();
198+
boundary_normals_bind.resize(boundary_normals.size());
199+
for (int i = 0; i < boundary_normals.size(); i++) {
200+
const VectorN &cell_face_normal = boundary_normals[i];
201+
boundary_normals_bind[i] = cell_face_normal;
202202
}
203-
return face_normals_bind;
203+
return boundary_normals_bind;
204204
}
205205

206206
TypedArray<VectorN> CellMeshND::get_simplex_cell_vertex_normals_bind() {
@@ -263,9 +263,9 @@ Vector<PackedInt32Array> CellMeshND::decompose_polytope_cell_into_simplexes(cons
263263
continue;
264264
}
265265
// This face is not a simplex, so we need to recurse.
266-
Vector<VectorN> face_normals = p_poly_cell_normals;
267-
face_normals.append(out_normals[i]);
268-
Vector<PackedInt32Array> lower_simplexes = decompose_polytope_cell_into_simplexes(p_vertices, face, p_dimension - 1, pivot_item, face_normals);
266+
Vector<VectorN> boundary_normals = p_poly_cell_normals;
267+
boundary_normals.append(out_normals[i]);
268+
Vector<PackedInt32Array> lower_simplexes = decompose_polytope_cell_into_simplexes(p_vertices, face, p_dimension - 1, pivot_item, boundary_normals);
269269
for (PackedInt32Array &lower_simplex : lower_simplexes) {
270270
lower_simplex.insert(0, pivot_item);
271271
simplexes.append(lower_simplex);
@@ -328,10 +328,10 @@ void CellMeshND::_bind_methods() {
328328

329329
ClassDB::bind_static_method("CellMeshND", D_METHOD("calculate_edge_indices_from_simplex_cell_indices", "simplex_cell_indices", "dimension", "deduplicate"), &CellMeshND::calculate_edge_indices_from_simplex_cell_indices);
330330
ClassDB::bind_method(D_METHOD("get_simplex_cell_indices"), &CellMeshND::get_simplex_cell_indices);
331-
ClassDB::bind_method(D_METHOD("get_simplex_cell_face_normals"), &CellMeshND::get_simplex_cell_face_normals_bind);
331+
ClassDB::bind_method(D_METHOD("get_simplex_cell_boundary_normals"), &CellMeshND::get_simplex_cell_boundary_normals_bind);
332332
ClassDB::bind_method(D_METHOD("get_simplex_cell_vertex_normals"), &CellMeshND::get_simplex_cell_vertex_normals_bind);
333333

334334
GDVIRTUAL_BIND(_get_simplex_cell_indices);
335-
GDVIRTUAL_BIND(_get_simplex_cell_face_normals);
335+
GDVIRTUAL_BIND(_get_simplex_cell_boundary_normals);
336336
GDVIRTUAL_BIND(_get_simplex_cell_vertex_normals);
337337
}

model/mesh/cell/cell_mesh_nd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class CellMeshND : public MeshND {
2727
virtual int get_simplex_cell_count();
2828
virtual int get_indices_per_simplex_cell();
2929
virtual PackedInt32Array get_simplex_cell_indices();
30-
virtual Vector<VectorN> get_simplex_cell_face_normals();
30+
virtual Vector<VectorN> get_simplex_cell_boundary_normals();
3131
virtual Vector<VectorN> get_simplex_cell_vertex_normals();
3232
Vector<VectorN> get_simplex_cell_positions();
33-
TypedArray<VectorN> get_simplex_cell_face_normals_bind();
33+
TypedArray<VectorN> get_simplex_cell_boundary_normals_bind();
3434
TypedArray<VectorN> get_simplex_cell_vertex_normals_bind();
3535
TypedArray<VectorN> get_simplex_cell_positions_bind();
3636

@@ -41,6 +41,6 @@ class CellMeshND : public MeshND {
4141
virtual Vector<VectorN> get_edge_positions() override;
4242

4343
GDVIRTUAL0R(PackedInt32Array, _get_simplex_cell_indices);
44-
GDVIRTUAL0R(TypedArray<VectorN>, _get_simplex_cell_face_normals);
44+
GDVIRTUAL0R(TypedArray<VectorN>, _get_simplex_cell_boundary_normals);
4545
GDVIRTUAL0R(TypedArray<VectorN>, _get_simplex_cell_vertex_normals);
4646
};

0 commit comments

Comments
 (0)