Cleanup: Remove includes and "using std" for opensubdiv wrapper
Avoid unnecessary indirect includes for the module, which would slow down compilation. Avoid "using std" which is generally not considered good practice since it's helpful to see what namespace things are from. This is just a general cleanup of the area. I was trying to understand it better to reduce redundant mesh topology storage but finding that some intermediate cleanups would be helpful to ease the change. Pull Request: https://projects.blender.org/blender/blender/pulls/120743
This commit is contained in:
@@ -37,7 +37,6 @@ if(WITH_OPENSUBDIV)
|
||||
# Base.
|
||||
internal/base/memory.h
|
||||
internal/base/opensubdiv_capi.cc
|
||||
internal/base/type.h
|
||||
internal/base/type_convert.cc
|
||||
internal/base/type_convert.h
|
||||
internal/base/util.cc
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2013 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#ifndef OPENSUBDIV_BASE_TYPE_H_
|
||||
#define OPENSUBDIV_BASE_TYPE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace blender {
|
||||
namespace opensubdiv {
|
||||
|
||||
using std::map;
|
||||
using std::pair;
|
||||
using std::stack;
|
||||
using std::string;
|
||||
using std::unordered_map;
|
||||
using std::vector;
|
||||
|
||||
using std::fill;
|
||||
using std::make_pair;
|
||||
using std::max;
|
||||
using std::min;
|
||||
using std::move;
|
||||
using std::swap;
|
||||
|
||||
} // namespace opensubdiv
|
||||
} // namespace blender
|
||||
|
||||
#endif // OPENSUBDIV_BASE_TYPE_H_
|
||||
@@ -7,22 +7,22 @@
|
||||
namespace blender {
|
||||
namespace opensubdiv {
|
||||
|
||||
void stringSplit(vector<string> *tokens,
|
||||
const string &str,
|
||||
const string &separators,
|
||||
void stringSplit(std::vector<std::string> *tokens,
|
||||
const std::string &str,
|
||||
const std::string &separators,
|
||||
bool skip_empty)
|
||||
{
|
||||
size_t token_start = 0, token_length = 0;
|
||||
for (size_t i = 0; i < str.length(); ++i) {
|
||||
const char ch = str[i];
|
||||
if (separators.find(ch) == string::npos) {
|
||||
if (separators.find(ch) == std::string::npos) {
|
||||
// Append non-separator char to a token.
|
||||
++token_length;
|
||||
}
|
||||
else {
|
||||
// Append current token to the list (if any).
|
||||
if (token_length > 0 || !skip_empty) {
|
||||
string token = str.substr(token_start, token_length);
|
||||
std::string token = str.substr(token_start, token_length);
|
||||
tokens->push_back(token);
|
||||
}
|
||||
// Re-set token pointers.
|
||||
@@ -30,11 +30,11 @@ void stringSplit(vector<string> *tokens,
|
||||
token_length = 0;
|
||||
}
|
||||
}
|
||||
// Append token which might be at the end of the string.
|
||||
if ((token_length != 0) ||
|
||||
(!skip_empty && token_start > 0 && separators.find(str[token_start - 1]) != string::npos))
|
||||
// Append token which might be at the end of the std::string.
|
||||
if ((token_length != 0) || (!skip_empty && token_start > 0 &&
|
||||
separators.find(str[token_start - 1]) != std::string::npos))
|
||||
{
|
||||
string token = str.substr(token_start, token_length);
|
||||
std::string token = str.substr(token_start, token_length);
|
||||
tokens->push_back(token);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,14 +5,15 @@
|
||||
#ifndef OPENSUBDIV_BASE_UTIL_H_
|
||||
#define OPENSUBDIV_BASE_UTIL_H_
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace blender {
|
||||
namespace opensubdiv {
|
||||
|
||||
void stringSplit(vector<string> *tokens,
|
||||
const string &str,
|
||||
const string &separators,
|
||||
void stringSplit(std::vector<std::string> *tokens,
|
||||
const std::string &str,
|
||||
const std::string &separators,
|
||||
bool skip_empty);
|
||||
|
||||
} // namespace opensubdiv
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <opensubdiv/osd/mesh.h>
|
||||
#include <opensubdiv/osd/types.h>
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include "internal/evaluator/evaluator_impl.h"
|
||||
|
||||
#include "opensubdiv_evaluator_capi.hh"
|
||||
@@ -325,7 +324,7 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
|
||||
|
||||
VolatileEvalOutput(const StencilTable *vertex_stencils,
|
||||
const StencilTable *varying_stencils,
|
||||
const vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const std::vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const int face_varying_width,
|
||||
const PatchTable *patch_table,
|
||||
EvaluatorCache *evaluator_cache = NULL,
|
||||
@@ -641,7 +640,7 @@ class VolatileEvalOutput : public EvalOutputAPI::EvalOutput {
|
||||
const STENCIL_TABLE *varying_stencils_;
|
||||
|
||||
int face_varying_width_;
|
||||
vector<FaceVaryingEval *> face_varying_evaluators_;
|
||||
std::vector<FaceVaryingEval *> face_varying_evaluators_;
|
||||
|
||||
EvaluatorCache *evaluator_cache_;
|
||||
DEVICE_CONTEXT *device_context_;
|
||||
|
||||
@@ -30,7 +30,7 @@ class CpuEvalOutput : public VolatileEvalOutput<CpuVertexBuffer,
|
||||
public:
|
||||
CpuEvalOutput(const StencilTable *vertex_stencils,
|
||||
const StencilTable *varying_stencils,
|
||||
const vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const std::vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const int face_varying_width,
|
||||
const PatchTable *patch_table,
|
||||
EvaluatorCache *evaluator_cache = NULL)
|
||||
|
||||
@@ -31,7 +31,7 @@ static void buildPatchArraysBufferFromVector(const PatchArrayVector &patch_array
|
||||
|
||||
GpuEvalOutput::GpuEvalOutput(const StencilTable *vertex_stencils,
|
||||
const StencilTable *varying_stencils,
|
||||
const vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const std::vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const int face_varying_width,
|
||||
const PatchTable *patch_table,
|
||||
VolatileEvalOutput::EvaluatorCache *evaluator_cache)
|
||||
|
||||
@@ -26,7 +26,7 @@ class GpuEvalOutput : public VolatileEvalOutput<GLVertexBuffer,
|
||||
public:
|
||||
GpuEvalOutput(const StencilTable *vertex_stencils,
|
||||
const StencilTable *varying_stencils,
|
||||
const vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const std::vector<const StencilTable *> &all_face_varying_stencils,
|
||||
const int face_varying_width,
|
||||
const PatchTable *patch_table,
|
||||
EvaluatorCache *evaluator_cache = NULL);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include "internal/evaluator/eval_output_cpu.h"
|
||||
#include "internal/evaluator/eval_output_gpu.h"
|
||||
#include "internal/evaluator/evaluator_cache_impl.h"
|
||||
@@ -90,7 +89,8 @@ template<typename T, int kNumMaxElementsOnStack> class StackOrHeapArray {
|
||||
T *old_buffer = effective_elements_;
|
||||
effective_elements_ = allocate(num_elements);
|
||||
if (old_buffer != effective_elements_) {
|
||||
memcpy(effective_elements_, old_buffer, sizeof(T) * min(old_num_elements, num_elements));
|
||||
memcpy(
|
||||
effective_elements_, old_buffer, sizeof(T) * std::min(old_num_elements, num_elements));
|
||||
}
|
||||
if (old_buffer != stack_elements_) {
|
||||
delete[] old_buffer;
|
||||
@@ -430,7 +430,6 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal(
|
||||
eOpenSubdivEvaluator evaluator_type,
|
||||
OpenSubdiv_EvaluatorCacheImpl *evaluator_cache_descr)
|
||||
{
|
||||
using blender::opensubdiv::vector;
|
||||
TopologyRefiner *refiner = topology_refiner->impl->topology_refiner;
|
||||
if (refiner == NULL) {
|
||||
// Happens on bad topology.
|
||||
@@ -480,7 +479,7 @@ OpenSubdiv_EvaluatorImpl *openSubdiv_createEvaluatorInternal(
|
||||
varying_stencils = StencilTableFactory::Create(*refiner, varying_stencil_options);
|
||||
}
|
||||
// Face warying stencil.
|
||||
vector<const StencilTable *> all_face_varying_stencils;
|
||||
std::vector<const StencilTable *> all_face_varying_stencils;
|
||||
all_face_varying_stencils.reserve(num_face_varying_channels);
|
||||
for (int face_varying_channel = 0; face_varying_channel < num_face_varying_channels;
|
||||
++face_varying_channel)
|
||||
|
||||
@@ -222,8 +222,8 @@ bool MeshTopology::isFaceVertexIndicesEqual(int face_index,
|
||||
sizeof(int) * num_expected_face_vertex_indices) == 0;
|
||||
}
|
||||
|
||||
bool MeshTopology::isFaceVertexIndicesEqual(int face_index,
|
||||
const vector<int> &expected_face_vertex_indices) const
|
||||
bool MeshTopology::isFaceVertexIndicesEqual(
|
||||
int face_index, const std::vector<int> &expected_face_vertex_indices) const
|
||||
{
|
||||
return isFaceVertexIndicesEqual(
|
||||
face_index, expected_face_vertex_indices.size(), expected_face_vertex_indices.data());
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
#ifndef OPENSUBDIV_MESH_TOPOLOGY_H_
|
||||
#define OPENSUBDIV_MESH_TOPOLOGY_H_
|
||||
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include "internal/base/memory.h"
|
||||
#include "internal/base/type.h"
|
||||
|
||||
struct OpenSubdiv_Converter;
|
||||
|
||||
@@ -93,7 +92,7 @@ class MeshTopology {
|
||||
int num_expected_face_vertex_indices,
|
||||
const int *expected_face_vertex_indices) const;
|
||||
bool isFaceVertexIndicesEqual(int face_index,
|
||||
const vector<int> &expected_face_vertex_indices) const;
|
||||
const std::vector<int> &expected_face_vertex_indices) const;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Pipeline related.
|
||||
@@ -142,21 +141,21 @@ class MeshTopology {
|
||||
};
|
||||
|
||||
int num_vertices_;
|
||||
vector<VertexTag> vertex_tags_;
|
||||
std::vector<VertexTag> vertex_tags_;
|
||||
|
||||
int num_edges_;
|
||||
vector<Edge> edges_;
|
||||
vector<EdgeTag> edge_tags_;
|
||||
std::vector<Edge> edges_;
|
||||
std::vector<EdgeTag> edge_tags_;
|
||||
|
||||
int num_faces_;
|
||||
|
||||
// Continuous array of all vertices of all faces:
|
||||
// [vertex indices of face 0][vertex indices of face 1] .. [vertex indices of face n].
|
||||
vector<int> face_vertex_indices_;
|
||||
std::vector<int> face_vertex_indices_;
|
||||
|
||||
// Indexed by face contains index within face_vertex_indices_ which corresponds
|
||||
// to the element which contains first vertex of the face.
|
||||
vector<int> faces_first_vertex_index_;
|
||||
std::vector<int> faces_first_vertex_index_;
|
||||
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("MeshTopology");
|
||||
};
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <opensubdiv/sdc/crease.h>
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include <vector>
|
||||
|
||||
#include "opensubdiv_converter_capi.hh"
|
||||
|
||||
@@ -80,7 +79,7 @@ bool isEqualGeometryFace(const MeshTopology &mesh_topology, const OpenSubdiv_Con
|
||||
return false;
|
||||
}
|
||||
|
||||
vector<int> vertices_of_face;
|
||||
std::vector<int> vertices_of_face;
|
||||
for (int face_index = 0; face_index < num_requested_faces; ++face_index) {
|
||||
int num_face_vertices = converter->getNumFaceVertices(converter, face_index);
|
||||
if (mesh_topology.getNumFaceVertices(face_index) != num_face_vertices) {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "internal/base/type_convert.h"
|
||||
#include "internal/topology/topology_refiner_impl.h"
|
||||
|
||||
using blender::opensubdiv::vector;
|
||||
|
||||
namespace {
|
||||
|
||||
const OpenSubdiv::Far::TopologyRefiner *getOSDTopologyRefiner(
|
||||
|
||||
@@ -15,16 +15,11 @@
|
||||
|
||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include "internal/base/type_convert.h"
|
||||
#include "internal/topology/mesh_topology.h"
|
||||
|
||||
#include "opensubdiv_converter_capi.hh"
|
||||
|
||||
using blender::opensubdiv::min;
|
||||
using blender::opensubdiv::stack;
|
||||
using blender::opensubdiv::vector;
|
||||
|
||||
struct TopologyRefinerData {
|
||||
const OpenSubdiv_Converter *converter;
|
||||
blender::opensubdiv::MeshTopology *base_mesh_topology;
|
||||
@@ -138,7 +133,7 @@ inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology
|
||||
|
||||
// Vertex relations.
|
||||
const int num_vertices = converter->getNumVertices(converter);
|
||||
vector<int> vertex_faces, vertex_edges;
|
||||
std::vector<int> vertex_faces, vertex_edges;
|
||||
for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) {
|
||||
// Vertex-faces.
|
||||
IndexArray dst_vertex_faces = getBaseVertexFaces(refiner, vertex_index);
|
||||
@@ -247,8 +242,8 @@ inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTags(
|
||||
const float sharpness0 = refiner._levels[0]->getEdgeSharpness(edge0);
|
||||
const float sharpness1 = refiner._levels[0]->getEdgeSharpness(edge1);
|
||||
// TODO(sergey): Find a better mixing between edge and vertex sharpness.
|
||||
sharpness += min(sharpness0, sharpness1);
|
||||
sharpness = min(sharpness, 10.0f);
|
||||
sharpness += std::min(sharpness0, sharpness1);
|
||||
sharpness = std::min(sharpness, 10.0f);
|
||||
}
|
||||
|
||||
setBaseVertexSharpness(refiner, vertex_index, sharpness);
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include "internal/topology/topology_refiner_impl.h"
|
||||
|
||||
#include "internal/base/type.h"
|
||||
#include "internal/base/type_convert.h"
|
||||
#include "internal/topology/mesh_topology.h"
|
||||
#include "internal/topology/topology_refiner_impl.h"
|
||||
|
||||
Reference in New Issue
Block a user