Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-07-30 22:08:43 +0300
committerHans Goudey <h.goudey@me.com>2021-07-30 22:08:43 +0300
commit35894dc700e035da914fb8457ef62706c5835391 (patch)
tree13ac3b85bb2216ee425fd40c5702517942127b1c /intern/openvdb
parent54bd5efa6881dbc59f732a17593f4cf03037f9a0 (diff)
Cleanup: Simplify logic, follow style guide for integer types
- Use `int` instead of `unsigned int` for mesh indices - Use C++ types (Array, float3, IndexRange) - Use range based for loops
Diffstat (limited to 'intern/openvdb')
-rw-r--r--intern/openvdb/intern/openvdb_level_set.cc19
-rw-r--r--intern/openvdb/intern/openvdb_level_set.h6
-rw-r--r--intern/openvdb/openvdb_capi.cc12
-rw-r--r--intern/openvdb/openvdb_capi.h22
4 files changed, 28 insertions, 31 deletions
diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc
index ed0020a66ce..5b01c3b0cb7 100644
--- a/intern/openvdb/intern/openvdb_level_set.cc
+++ b/intern/openvdb/intern/openvdb_level_set.cc
@@ -33,20 +33,20 @@ OpenVDBLevelSet::~OpenVDBLevelSet()
}
void OpenVDBLevelSet::mesh_to_level_set(const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
const openvdb::math::Transform::Ptr &xform)
{
std::vector<openvdb::Vec3s> points(totvertices);
std::vector<openvdb::Vec3I> triangles(totfaces);
std::vector<openvdb::Vec4I> quads;
- for (unsigned int i = 0; i < totvertices; i++) {
+ for (int i = 0; i < totvertices; i++) {
points[i] = openvdb::Vec3s(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]);
}
- for (unsigned int i = 0; i < totfaces; i++) {
+ for (int i = 0; i < totfaces; i++) {
triangles[i] = openvdb::Vec3I(faces[i * 3], faces[i * 3 + 1], faces[i * 3 + 2]);
}
@@ -69,14 +69,11 @@ void OpenVDBLevelSet::volume_to_mesh(OpenVDBVolumeToMeshData *mesh,
isovalue,
adaptivity,
relax_disoriented_triangles);
- mesh->vertices = (float *)MEM_malloc_arrayN(
- out_points.size(), 3 * sizeof(float), "openvdb remesher out verts");
- mesh->quads = (unsigned int *)MEM_malloc_arrayN(
- out_quads.size(), 4 * sizeof(unsigned int), "openvdb remesh out quads");
+ mesh->vertices = (float *)MEM_malloc_arrayN(out_points.size(), sizeof(float[3]), __func__);
+ mesh->quads = (int *)MEM_malloc_arrayN(out_quads.size(), sizeof(int[4]), __func__);
mesh->triangles = NULL;
if (out_tris.size() > 0) {
- mesh->triangles = (unsigned int *)MEM_malloc_arrayN(
- out_tris.size(), 3 * sizeof(unsigned int), "openvdb remesh out tris");
+ mesh->triangles = (int *)MEM_malloc_arrayN(out_tris.size(), sizeof(int[3]), __func__);
}
mesh->totvertices = out_points.size();
diff --git a/intern/openvdb/intern/openvdb_level_set.h b/intern/openvdb/intern/openvdb_level_set.h
index 882958513fd..2c8f140c012 100644
--- a/intern/openvdb/intern/openvdb_level_set.h
+++ b/intern/openvdb/intern/openvdb_level_set.h
@@ -39,9 +39,9 @@ struct OpenVDBLevelSet {
void set_grid(const openvdb::FloatGrid::Ptr &grid);
void mesh_to_level_set(const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
const openvdb::math::Transform::Ptr &transform);
void volume_to_mesh(struct OpenVDBVolumeToMeshData *mesh,
diff --git a/intern/openvdb/openvdb_capi.cc b/intern/openvdb/openvdb_capi.cc
index e7a4bf335fc..674b394fa46 100644
--- a/intern/openvdb/openvdb_capi.cc
+++ b/intern/openvdb/openvdb_capi.cc
@@ -63,9 +63,9 @@ void OpenVDBLevelSet_free(OpenVDBLevelSet *level_set)
void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
OpenVDBTransform *xform)
{
level_set->mesh_to_level_set(vertices, faces, totvertices, totfaces, xform->get_transform());
@@ -73,9 +73,9 @@ void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
void OpenVDBLevelSet_mesh_to_level_set_transform(struct OpenVDBLevelSet *level_set,
const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
OpenVDBTransform *transform)
{
level_set->mesh_to_level_set(vertices, faces, totvertices, totfaces, transform->get_transform());
diff --git a/intern/openvdb/openvdb_capi.h b/intern/openvdb/openvdb_capi.h
index 98d89c340bf..9333413c2fe 100644
--- a/intern/openvdb/openvdb_capi.h
+++ b/intern/openvdb/openvdb_capi.h
@@ -67,19 +67,19 @@ struct OpenVDBVolumeToMeshData {
int totvertices;
float *vertices;
- unsigned int *quads;
- unsigned int *triangles;
+ int *quads;
+ int *triangles;
};
struct OpenVDBRemeshData {
float *verts;
- unsigned int *faces;
+ int *faces;
int totfaces;
int totverts;
float *out_verts;
- unsigned int *out_faces;
- unsigned int *out_tris;
+ int *out_faces;
+ int *out_tris;
int out_totverts;
int out_totfaces;
int out_tottris;
@@ -112,15 +112,15 @@ struct OpenVDBLevelSet *OpenVDBLevelSet_create(bool initGrid, struct OpenVDBTran
void OpenVDBLevelSet_free(struct OpenVDBLevelSet *level_set);
void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set,
const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
struct OpenVDBTransform *xform);
void OpenVDBLevelSet_mesh_to_level_set_transform(struct OpenVDBLevelSet *level_set,
const float *vertices,
- const unsigned int *faces,
- const unsigned int totvertices,
- const unsigned int totfaces,
+ const int *faces,
+ const int totvertices,
+ const int totfaces,
struct OpenVDBTransform *transform);
void OpenVDBLevelSet_volume_to_mesh(struct OpenVDBLevelSet *level_set,
struct OpenVDBVolumeToMeshData *mesh,