mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-18 07:17:18 +01:00
Fix Mesh::get_face_count()
This fixes a minor bug whereby facecount was actually returning the facecount * 3. There were no major problems from this, but it did mean the optional threshold poly count used when merging was out by a factor of 3.
This commit is contained in:
parent
d699df272f
commit
da78ed110a
@ -328,7 +328,7 @@ void MergeGroupEditorPlugin::_remove_queue_deleted_nodes_recursive(Node *p_node)
|
|||||||
uint32_t MergeGroupEditorPlugin::_get_mesh_poly_count(const MeshInstance &p_mi) const {
|
uint32_t MergeGroupEditorPlugin::_get_mesh_poly_count(const MeshInstance &p_mi) const {
|
||||||
Ref<Mesh> rmesh = p_mi.get_mesh();
|
Ref<Mesh> rmesh = p_mi.get_mesh();
|
||||||
if (rmesh.is_valid()) {
|
if (rmesh.is_valid()) {
|
||||||
return rmesh->get_face_count();
|
return rmesh->get_triangle_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
Mesh::ConvexDecompositionFunc Mesh::convex_decomposition_function = nullptr;
|
Mesh::ConvexDecompositionFunc Mesh::convex_decomposition_function = nullptr;
|
||||||
|
|
||||||
int Mesh::surface_get_face_count(int p_idx) const {
|
int Mesh::surface_get_triangle_count(int p_idx) const {
|
||||||
ERR_FAIL_INDEX_V(p_idx, get_surface_count(), 0);
|
ERR_FAIL_INDEX_V(p_idx, get_surface_count(), 0);
|
||||||
|
|
||||||
switch (surface_get_primitive_type(p_idx)) {
|
switch (surface_get_primitive_type(p_idx)) {
|
||||||
@ -51,14 +51,14 @@ int Mesh::surface_get_face_count(int p_idx) const {
|
|||||||
int len = (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? surface_get_array_index_len(p_idx) : surface_get_array_len(p_idx);
|
int len = (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? surface_get_array_index_len(p_idx) : surface_get_array_len(p_idx);
|
||||||
// Don't error if zero, it's valid (we'll just skip it later).
|
// Don't error if zero, it's valid (we'll just skip it later).
|
||||||
ERR_FAIL_COND_V_MSG((len % 3) != 0, 0, vformat("Ignoring surface %d, incorrect %s count: %d (for PRIMITIVE_TRIANGLES).", p_idx, (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? "index" : "vertex", len));
|
ERR_FAIL_COND_V_MSG((len % 3) != 0, 0, vformat("Ignoring surface %d, incorrect %s count: %d (for PRIMITIVE_TRIANGLES).", p_idx, (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? "index" : "vertex", len));
|
||||||
return len;
|
return len / 3;
|
||||||
} break;
|
} break;
|
||||||
case PRIMITIVE_TRIANGLE_FAN:
|
case PRIMITIVE_TRIANGLE_FAN:
|
||||||
case PRIMITIVE_TRIANGLE_STRIP: {
|
case PRIMITIVE_TRIANGLE_STRIP: {
|
||||||
int len = (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? surface_get_array_index_len(p_idx) : surface_get_array_len(p_idx);
|
int len = (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? surface_get_array_index_len(p_idx) : surface_get_array_len(p_idx);
|
||||||
// Don't error if zero, it's valid (we'll just skip it later).
|
// Don't error if zero, it's valid (we'll just skip it later).
|
||||||
ERR_FAIL_COND_V_MSG(len != 0 && len < 3, 0, vformat("Ignoring surface %d, incorrect %s count: %d (for %s).", p_idx, (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? "index" : "vertex", len, (surface_get_primitive_type(p_idx) == PRIMITIVE_TRIANGLE_FAN) ? "PRIMITIVE_TRIANGLE_FAN" : "PRIMITIVE_TRIANGLE_STRIP"));
|
ERR_FAIL_COND_V_MSG(len != 0 && len < 3, 0, vformat("Ignoring surface %d, incorrect %s count: %d (for %s).", p_idx, (surface_get_format(p_idx) & ARRAY_FORMAT_INDEX) ? "index" : "vertex", len, (surface_get_primitive_type(p_idx) == PRIMITIVE_TRIANGLE_FAN) ? "PRIMITIVE_TRIANGLE_FAN" : "PRIMITIVE_TRIANGLE_STRIP"));
|
||||||
return (len == 0) ? 0 : (len - 2) * 3;
|
return (len == 0) ? 0 : (len - 2);
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
} break;
|
} break;
|
||||||
@ -67,14 +67,14 @@ int Mesh::surface_get_face_count(int p_idx) const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Mesh::get_face_count() const {
|
int Mesh::get_triangle_count() const {
|
||||||
int faces_size = 0;
|
int triangle_count = 0;
|
||||||
|
|
||||||
for (int i = 0; i < get_surface_count(); i++) {
|
for (int i = 0; i < get_surface_count(); i++) {
|
||||||
faces_size += surface_get_face_count(i);
|
triangle_count += surface_get_triangle_count(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return faces_size;
|
return triangle_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<TriangleMesh> Mesh::generate_triangle_mesh_from_aabb() const {
|
Ref<TriangleMesh> Mesh::generate_triangle_mesh_from_aabb() const {
|
||||||
@ -152,14 +152,14 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
|
|||||||
return triangle_mesh;
|
return triangle_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
int faces_size = get_face_count();
|
int faces_vertex_count = get_triangle_count() * 3;
|
||||||
|
|
||||||
if (faces_size == 0) {
|
if (faces_vertex_count == 0) {
|
||||||
return triangle_mesh;
|
return triangle_mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolVector<Vector3> faces;
|
PoolVector<Vector3> faces;
|
||||||
faces.resize(faces_size);
|
faces.resize(faces_vertex_count);
|
||||||
PoolVector<Vector3>::Write facesw = faces.write();
|
PoolVector<Vector3>::Write facesw = faces.write();
|
||||||
|
|
||||||
int widx = 0;
|
int widx = 0;
|
||||||
|
@ -138,11 +138,11 @@ public:
|
|||||||
virtual void surface_set_material(int p_idx, const Ref<Material> &p_material) = 0;
|
virtual void surface_set_material(int p_idx, const Ref<Material> &p_material) = 0;
|
||||||
virtual Ref<Material> surface_get_material(int p_idx) const = 0;
|
virtual Ref<Material> surface_get_material(int p_idx) const = 0;
|
||||||
virtual int get_blend_shape_count() const = 0;
|
virtual int get_blend_shape_count() const = 0;
|
||||||
int surface_get_face_count(int p_idx) const;
|
int surface_get_triangle_count(int p_idx) const;
|
||||||
virtual StringName get_blend_shape_name(int p_index) const = 0;
|
virtual StringName get_blend_shape_name(int p_index) const = 0;
|
||||||
virtual void set_blend_shape_name(int p_index, const StringName &p_name) = 0;
|
virtual void set_blend_shape_name(int p_index, const StringName &p_name) = 0;
|
||||||
|
|
||||||
int get_face_count() const;
|
int get_triangle_count() const;
|
||||||
PoolVector<Face3> get_faces() const;
|
PoolVector<Face3> get_faces() const;
|
||||||
Ref<TriangleMesh> generate_triangle_mesh() const;
|
Ref<TriangleMesh> generate_triangle_mesh() const;
|
||||||
Ref<TriangleMesh> generate_triangle_mesh_from_aabb() const;
|
Ref<TriangleMesh> generate_triangle_mesh_from_aabb() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user