diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc')
-rw-r--r-- | intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc | 76 |
1 files changed, 35 insertions, 41 deletions
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc index 32787ef05a3..6efbe93d2d8 100644 --- a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc +++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc @@ -28,16 +28,17 @@ namespace opensubdiv_capi { //////////////////////////////////////////////////////////////////////////////// // GLMeshFVarData -GLMeshFVarData::GLMeshFVarData() - : texture_buffer(0), - offset_buffer(0) { +GLMeshFVarData::GLMeshFVarData() : texture_buffer(0), offset_buffer(0) +{ } -GLMeshFVarData::~GLMeshFVarData() { +GLMeshFVarData::~GLMeshFVarData() +{ release(); } -void GLMeshFVarData::release() { +void GLMeshFVarData::release() +{ if (texture_buffer) { glDeleteTextures(1, &texture_buffer); } @@ -50,11 +51,11 @@ void GLMeshFVarData::release() { channel_offsets.clear(); } -void GLMeshFVarData::create( - const OpenSubdiv::Far::TopologyRefiner* topology_refiner, - const OpenSubdiv::Far::PatchTable* patch_table, - int fvar_width, - const float* fvar_src_data) { +void GLMeshFVarData::create(const OpenSubdiv::Far::TopologyRefiner *topology_refiner, + const OpenSubdiv::Far::PatchTable *patch_table, + int fvar_width, + const float *fvar_src_data) +{ release(); this->fvar_width = fvar_width; /// Expand fvar data to per-patch array. @@ -64,8 +65,7 @@ void GLMeshFVarData::create( int fvar_data_offset = 0; channel_offsets.resize(num_channels); for (int channel = 0; channel < num_channels; ++channel) { - OpenSubdiv::Far::ConstIndexArray indices = - patch_table->GetFVarValues(channel); + OpenSubdiv::Far::ConstIndexArray indices = patch_table->GetFVarValues(channel); channel_offsets[channel] = data.size(); data.reserve(data.size() + indices.size() * fvar_width); for (int fvert = 0; fvert < indices.size(); ++fvert) { @@ -75,31 +75,26 @@ void GLMeshFVarData::create( } } if (topology_refiner->IsUniform()) { - const int num_values_max = - topology_refiner->GetLevel(max_level).GetNumFVarValues(channel); + const int num_values_max = topology_refiner->GetLevel(max_level).GetNumFVarValues(channel); fvar_data_offset += num_values_max * fvar_width; - } else { - const int num_values_total = - topology_refiner->GetNumFVarValuesTotal(channel); + } + else { + const int num_values_total = topology_refiner->GetNumFVarValuesTotal(channel); fvar_data_offset += num_values_total * fvar_width; } } GLuint buffer; glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, - data.size() * sizeof(float), &data[0], - GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, data.size() * sizeof(float), &data[0], GL_STATIC_DRAW); glGenTextures(1, &texture_buffer); glBindTexture(GL_TEXTURE_BUFFER, texture_buffer); glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, buffer); glDeleteBuffers(1, &buffer); glGenBuffers(1, &buffer); glBindBuffer(GL_ARRAY_BUFFER, buffer); - glBufferData(GL_ARRAY_BUFFER, - channel_offsets.size() * sizeof(int), - &channel_offsets[0], - GL_STATIC_DRAW); + glBufferData( + GL_ARRAY_BUFFER, channel_offsets.size() * sizeof(int), &channel_offsets[0], GL_STATIC_DRAW); glGenTextures(1, &offset_buffer); glBindTexture(GL_TEXTURE_BUFFER, offset_buffer); glTexBuffer(GL_TEXTURE_BUFFER, GL_R32I, buffer); @@ -113,26 +108,28 @@ void GLMeshFVarData::create( struct FVarVertex { float u, v; - void Clear() { + void Clear() + { u = v = 0.0f; } - void AddWithWeight(FVarVertex const& src, float weight) { + void AddWithWeight(FVarVertex const &src, float weight) + { u += weight * src.u; v += weight * src.v; } }; -void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner, - const vector<float>& uvs, - vector<float>* fvar_data) { +void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner &refiner, + const vector<float> &uvs, + vector<float> *fvar_data) +{ const int fvar_width = 2; const int max_level = refiner.GetMaxLevel(); size_t fvar_data_offset = 0, values_offset = 0; for (int channel = 0; channel < refiner.GetNumFVarChannels(); ++channel) { const int num_values = refiner.GetLevel(0).GetNumFVarValues(channel) * 2; - const int num_values_max = - refiner.GetLevel(max_level).GetNumFVarValues(channel); + const int num_values_max = refiner.GetLevel(max_level).GetNumFVarValues(channel); const int num_values_total = refiner.GetNumFVarValuesTotal(channel); if (num_values_total <= 0) { continue; @@ -142,29 +139,26 @@ void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner, // For uniform we only keep the highest level of refinement. fvar_data->resize(fvar_data->size() + num_values_max * fvar_width); vector<FVarVertex> buffer(num_values_total - num_values_max); - FVarVertex* src = &buffer[0]; + FVarVertex *src = &buffer[0]; memcpy(src, &uvs[values_offset], num_values * sizeof(float)); // Defer the last level to treat separately with its alternate // destination. for (int level = 1; level < max_level; ++level) { - FVarVertex* dst = - src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); + FVarVertex *dst = src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); src = dst; } - FVarVertex* dst = - reinterpret_cast<FVarVertex*>(&(*fvar_data)[fvar_data_offset]); + FVarVertex *dst = reinterpret_cast<FVarVertex *>(&(*fvar_data)[fvar_data_offset]); primvar_refiner.InterpolateFaceVarying(max_level, src, dst, channel); fvar_data_offset += num_values_max * fvar_width; - } else { + } + else { // For adaptive we keep all levels. fvar_data->resize(fvar_data->size() + num_values_total * fvar_width); - FVarVertex* src = - reinterpret_cast<FVarVertex*>(&(*fvar_data)[fvar_data_offset]); + FVarVertex *src = reinterpret_cast<FVarVertex *>(&(*fvar_data)[fvar_data_offset]); memcpy(src, &uvs[values_offset], num_values * sizeof(float)); for (int level = 1; level <= max_level; ++level) { - FVarVertex* dst = - src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); + FVarVertex *dst = src + refiner.GetLevel(level - 1).GetNumFVarValues(channel); primvar_refiner.InterpolateFaceVarying(level, src, dst, channel); src = dst; } |