2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
|
|
|
|
2013-03-23 01:20:50 +00:00
|
|
|
#ifndef FAR_PATCH_TABLES_H
|
|
|
|
#define FAR_PATCH_TABLES_H
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
2013-03-25 14:32:17 +00:00
|
|
|
|
2015-01-27 23:38:30 +00:00
|
|
|
#include "../far/interpolate.h"
|
2014-11-25 20:41:19 +00:00
|
|
|
#include "../far/patchDescriptor.h"
|
2014-11-11 19:27:25 +00:00
|
|
|
#include "../far/stencilTables.h"
|
2015-02-26 21:57:47 +00:00
|
|
|
#include "../far/stencilTables.h"
|
|
|
|
|
|
|
|
#include "../sdc/options.h"
|
2013-05-17 16:47:44 +00:00
|
|
|
|
2013-05-09 16:23:01 +00:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
2013-06-11 22:59:43 +00:00
|
|
|
#include <algorithm>
|
2013-03-08 01:50:15 +00:00
|
|
|
#include <vector>
|
2013-05-17 22:46:29 +00:00
|
|
|
#include <map>
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
namespace Far {
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Container for arrays of parametric patches
|
2012-12-11 01:15:13 +00:00
|
|
|
///
|
2014-11-25 20:41:19 +00:00
|
|
|
/// PatchTables contain topology and parametric information about the patches
|
|
|
|
/// generated by the Refinement process. Patches in the tables are sorted into
|
|
|
|
/// arrays based on their PatchDescriptor Type.
|
2012-12-11 01:15:13 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// Note : PatchTables can be accessed either using a PatchHandle or a
|
|
|
|
/// combination of array and patch indices.
|
|
|
|
///
|
|
|
|
/// XXXX manuelk we should add a PatchIterator that can dereference into
|
|
|
|
/// a PatchHandle for fast linear traversal of the tables
|
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
class PatchTables {
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
public:
|
2014-10-09 21:48:50 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Handle that can be used as unique patch identifier within PatchTables
|
|
|
|
class PatchHandle {
|
2015-02-26 21:57:47 +00:00
|
|
|
// XXXX manuelk members will eventually be made private
|
2014-11-25 20:41:19 +00:00
|
|
|
public:
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
friend class PatchTables;
|
|
|
|
friend class PatchMap;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
Index arrayIndex, // Array index of the patch
|
|
|
|
patchIndex, // Absolute Index of the patch
|
|
|
|
vertIndex; // Relative offset to the first CV of the patch in array
|
2013-05-09 00:06:59 +00:00
|
|
|
};
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-10-09 21:48:50 +00:00
|
|
|
public:
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Copy constructor
|
|
|
|
PatchTables(PatchTables const & src);
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Destructor
|
|
|
|
~PatchTables();
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief True if the patches are of feature adaptive types
|
|
|
|
bool IsFeatureAdaptive() const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the total number of control vertex indices in the tables
|
|
|
|
int GetNumControlVerticesTotal() const {
|
|
|
|
return (int)_patchVerts.size();
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the total number of patches stored in the tables
|
|
|
|
int GetNumPatchesTotal() const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns max vertex valence
|
|
|
|
int GetMaxValence() const { return _maxValence; }
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the total number of ptex faces in the mesh
|
|
|
|
int GetNumPtexFaces() const { return _numPtexFaces; }
|
2014-02-25 01:12:39 +00:00
|
|
|
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@{
|
|
|
|
/// @name Individual patches
|
|
|
|
///
|
|
|
|
/// \anchor individual_patches
|
|
|
|
///
|
|
|
|
/// \brief Accessors for individual patches
|
|
|
|
///
|
2013-05-10 17:44:03 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the PatchDescriptor for the patches in array 'array'
|
|
|
|
PatchDescriptor GetPatchDescriptor(PatchHandle const & handle) const;
|
2013-05-09 20:14:02 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the control vertex indices for the patch identified by 'handle'
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstIndexArray GetPatchVertices(PatchHandle const & handle) const;
|
2013-05-09 20:14:02 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns a PatchParam for the patch identified by 'handle'
|
|
|
|
PatchParam GetPatchParam(PatchHandle const & handle) const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the control vertex indices for the patch 'patch' in array 'array'
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstIndexArray GetPatchVertices(int array, int patch) const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the PatchParam for the patch 'patch' in array 'array'
|
|
|
|
PatchParam GetPatchParam(int array, int patch) const;
|
|
|
|
//@}
|
2013-05-09 16:23:01 +00:00
|
|
|
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@{
|
|
|
|
/// @name Arrays of patches
|
|
|
|
///
|
|
|
|
/// \anchor arrays_of_patches
|
|
|
|
///
|
|
|
|
/// \brief Accessors for arrays of patches of the same type
|
|
|
|
///
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the number of patch arrays in the table
|
|
|
|
int GetNumPatchArrays() const;
|
2013-05-09 20:14:02 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the number of patches in patch array 'array'
|
|
|
|
int GetNumPatches(int array) const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the number of control vertices in patch array 'array'
|
|
|
|
int GetNumControlVertices(int array) const;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the PatchDescriptor for the patches in array 'array'
|
|
|
|
PatchDescriptor GetPatchArrayDescriptor(int array) const;
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the control vertex indices for the patches in array 'array'
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstIndexArray GetPatchArrayVertices(int array) const;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the PatchParams for the patches in array 'array'
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstPatchParamArray const GetPatchParams(int array) const;
|
2014-11-25 20:41:19 +00:00
|
|
|
//@}
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@{
|
|
|
|
/// @name End-Cap patches
|
2014-09-05 22:07:46 +00:00
|
|
|
///
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \anchor end_cap_patches
|
2014-09-05 22:07:46 +00:00
|
|
|
///
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Accessors for end-cap patch additional data
|
2014-09-05 22:07:46 +00:00
|
|
|
///
|
|
|
|
|
2014-12-15 18:23:13 +00:00
|
|
|
typedef Vtr::ConstArray<unsigned int> ConstQuadOffsetsArray;
|
2013-05-09 16:23:01 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the 'QuadOffsets' for the Gregory patch identified by 'handle'
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstQuadOffsetsArray GetPatchQuadOffsets(PatchHandle const & handle) const;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
typedef std::vector<Index> VertexValenceTable;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the 'VertexValences' table (vertex neighborhoods table)
|
|
|
|
VertexValenceTable const & GetVertexValenceTable() const {
|
|
|
|
return _vertexValenceTable;
|
|
|
|
}
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
/// \brief Returns a stencil table for the control vertices of end-cap patches
|
2015-04-08 01:34:05 +00:00
|
|
|
StencilTables const * GetEndCapVertexStencilTables() const { return _endcapVertexStencilTables; }
|
|
|
|
StencilTables const * GetEndCapVaryingStencilTables() const { return _endcapVaryingStencilTables; }
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@}
|
2013-03-23 01:20:50 +00:00
|
|
|
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@{
|
|
|
|
/// @name Single-crease patches
|
|
|
|
///
|
|
|
|
/// \anchor single_crease_patches
|
|
|
|
///
|
|
|
|
/// \brief Accessors for single-crease patch edge sharpness
|
|
|
|
///
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the crease sharpness for the patch identified by 'handle'
|
|
|
|
/// if it is a single-crease patch, or 0.0f
|
|
|
|
float GetSingleCreasePatchSharpnessValue(PatchHandle const & handle) const;
|
2014-03-25 02:13:40 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the crease sharpness for the patch 'patch' in array 'array'
|
|
|
|
/// if it is a single-crease patch, or 0.0f
|
|
|
|
float GetSingleCreasePatchSharpnessValue(int array, int patch) const;
|
|
|
|
//@}
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//@{
|
2015-02-26 21:57:47 +00:00
|
|
|
/// @name Face-varying channels
|
2014-11-25 20:41:19 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \anchor face_varying_channels
|
2014-09-05 22:07:46 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Accessors for face-varying channels
|
2014-09-05 22:07:46 +00:00
|
|
|
///
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns the number of face-varying channels
|
|
|
|
int GetNumFVarChannels() const;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns the interpolation mode for a given channel
|
|
|
|
Sdc::Options::FVarLinearInterpolation GetFVarChannelLinearInterpolation(int channel) const;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns a descriptor for a given patch in a channel
|
|
|
|
PatchDescriptor::Type GetFVarPatchType(int channel, PatchHandle const & handle) const;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns a descriptor for a given patch in a channel
|
|
|
|
PatchDescriptor::Type GetFVarPatchType(int channel, int array, int patch) const;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns an array of descriptors for the patches in a channel
|
|
|
|
Vtr::ConstArray<PatchDescriptor::Type> GetFVarPatchTypes(int channel) const;
|
2014-11-25 20:41:19 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Returns the value indices for a given patch in a channel
|
|
|
|
ConstIndexArray GetFVarPatchValues(int channel, PatchHandle const & handle) const;
|
|
|
|
|
|
|
|
/// \brief Returns the value indices for a given patch in a channel
|
|
|
|
ConstIndexArray GetFVarPatchValues(int channel, int array, int patch) const;
|
|
|
|
|
|
|
|
|
|
|
|
/// \brief Returns an array of value indices for the patches in a channel
|
|
|
|
ConstIndexArray GetFVarPatchesValues(int channel) const;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// @name Direct accessors
|
|
|
|
///
|
|
|
|
/// \warning These direct accessors are left for convenience, but they are
|
|
|
|
/// likely going to be deprecated in future releases
|
|
|
|
///
|
|
|
|
|
|
|
|
typedef std::vector<Index> PatchVertsTable;
|
|
|
|
|
|
|
|
/// \brief Get the table of patch control vertices
|
|
|
|
PatchVertsTable const & GetPatchControlVerticesTable() const { return _patchVerts; }
|
|
|
|
|
|
|
|
/// \brief Returns the PatchParamTable (PatchParams order matches patch array sorting)
|
|
|
|
PatchParamTable const & GetPatchParamTable() const { return _paramTable; }
|
|
|
|
|
|
|
|
/// \brief Returns a sharpness index table for each patch (if exists)
|
|
|
|
std::vector<Index> const &GetSharpnessIndexTable() const { return _sharpnessIndices; }
|
|
|
|
|
|
|
|
/// \brief Returns sharpness values table
|
|
|
|
std::vector<float> const &GetSharpnessValues() const { return _sharpnessValues; }
|
|
|
|
|
|
|
|
typedef std::vector<unsigned int> QuadOffsetsTable;
|
|
|
|
|
|
|
|
/// \brief Returns the quad-offsets table
|
|
|
|
QuadOffsetsTable const & GetQuadOffsetsTable() const {
|
|
|
|
return _quadOffsetsTable;
|
|
|
|
}
|
2014-11-25 20:41:19 +00:00
|
|
|
//@}
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// debug helper
|
|
|
|
void print() const;
|
|
|
|
|
2014-10-02 23:09:17 +00:00
|
|
|
public:
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
//@{
|
|
|
|
/// @name Interpolation methods
|
2014-10-02 23:09:17 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
/// \brief Interpolate the (s,t) parametric location of a *bilinear* patch
|
|
|
|
///
|
|
|
|
/// \note This method can only be used on uniform PatchTables of quads (see
|
|
|
|
/// IsFeatureAdaptive() method)
|
2014-09-19 00:48:34 +00:00
|
|
|
///
|
|
|
|
/// @param handle A patch handle indentifying the sub-patch containing the
|
|
|
|
/// (s,t) location
|
|
|
|
///
|
|
|
|
/// @param s Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
|
|
|
/// @param t Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
template <class T, class U> void EvaluateBilinear(PatchHandle const & handle,
|
2014-10-21 23:36:26 +00:00
|
|
|
float s, float t, T const & src, U & dst) const;
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-10-02 23:09:17 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Interpolate the (s,t) parametric location of a *bicubic* patch
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \note This method can only be used on feature adaptive PatchTables (ie.
|
|
|
|
/// IsFeatureAdaptive() is false)
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// @param handle A patch handle indentifying the sub-patch containing the
|
|
|
|
/// (s,t) location
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// @param s Patch coordinate (in coarse face normalized space)
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// @param t Patch coordinate (in coarse face normalized space)
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
template <class T, class U> void Evaluate(PatchHandle const & handle,
|
|
|
|
float s, float t, T const & src, U & dst) const;
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
/// \brief Interpolate the (s,t) parametric location of a *bicubic*
|
|
|
|
/// face-varying patch
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
/// @param channel The face-varying primvar channel
|
2014-10-02 23:09:17 +00:00
|
|
|
///
|
|
|
|
/// @param handle A patch handle indentifying the sub-patch containing the
|
|
|
|
/// (s,t) location
|
|
|
|
///
|
|
|
|
/// @param s Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
|
|
|
/// @param t Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
2015-02-26 21:57:47 +00:00
|
|
|
template <class T, class U> void EvaluateFaceVarying(int channel,
|
|
|
|
PatchHandle const & handle, float s, float t, T const & src, U & dst) const;
|
|
|
|
|
|
|
|
//@}
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
protected:
|
|
|
|
|
2014-12-25 21:03:53 +00:00
|
|
|
friend class PatchTablesFactory;
|
|
|
|
|
|
|
|
// Factory constructor
|
|
|
|
PatchTables(int maxvalence);
|
|
|
|
|
2015-01-28 23:50:23 +00:00
|
|
|
Index getPatchIndex(int array, int patch) const;
|
2015-02-26 21:57:47 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
PatchParamArray getPatchParams(int arrayIndex);
|
|
|
|
|
|
|
|
Index * getSharpnessIndices(Index arrayIndex);
|
|
|
|
float * getSharpnessValues(Index arrayIndex);
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
private:
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
//
|
|
|
|
// Patch arrays
|
|
|
|
//
|
2014-10-09 21:48:50 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
struct PatchArray;
|
2015-02-26 21:57:47 +00:00
|
|
|
typedef std::vector<PatchArray> PatchArrayVector;
|
2013-05-09 00:06:59 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
PatchArray & getPatchArray(Index arrayIndex);
|
|
|
|
PatchArray const & getPatchArray(Index arrayIndex) const;
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
void reservePatchArrays(int numPatchArrays);
|
|
|
|
void pushPatchArray(PatchDescriptor desc, int npatches,
|
|
|
|
Index * vidx, Index * pidx, Index * qoidx=0);
|
|
|
|
|
|
|
|
IndexArray getPatchArrayVertices(int arrayIndex);
|
|
|
|
|
|
|
|
Index findPatchArray(PatchDescriptor desc);
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// FVar patch channels
|
|
|
|
//
|
|
|
|
|
|
|
|
struct FVarPatchChannel;
|
|
|
|
typedef std::vector<FVarPatchChannel> FVarPatchChannelVector;
|
|
|
|
|
|
|
|
FVarPatchChannel & getFVarPatchChannel(int channel);
|
|
|
|
FVarPatchChannel const & getFVarPatchChannel(int channel) const;
|
|
|
|
|
|
|
|
void allocateFVarPatchChannels(int numChannels);
|
|
|
|
void allocateChannelValues(int channel, int numPatches, int numVerticesTotal);
|
|
|
|
|
|
|
|
void setFVarPatchChannelLinearInterpolation(int channel,
|
|
|
|
Sdc::Options::FVarLinearInterpolation interpolation);
|
|
|
|
|
|
|
|
void setFVarPatchChannelPatchesType(int channel, PatchDescriptor::Type type);
|
|
|
|
|
|
|
|
PatchDescriptor::Type getFVarPatchType(int channel, int patch) const;
|
|
|
|
Vtr::Array<PatchDescriptor::Type> getFVarPatchTypes(int channel);
|
|
|
|
|
|
|
|
IndexArray getFVarPatchesValues(int channel);
|
|
|
|
ConstIndexArray getFVarPatchValues(int channel, int patch) const;
|
|
|
|
|
|
|
|
void setBicubicFVarPatchChannelValues(int channel, int patchSize, std::vector<Index> const & values);
|
|
|
|
|
|
|
|
private:
|
2014-11-25 20:41:19 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
//
|
|
|
|
// Topology
|
|
|
|
//
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
int _maxValence, // highest vertex valence found in the mesh
|
|
|
|
_numPtexFaces; // total number of ptex faces
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
PatchArrayVector _patchArrays; // Vector of descriptors for arrays of patches
|
2014-11-25 20:41:19 +00:00
|
|
|
|
|
|
|
std::vector<Index> _patchVerts; // Indices of the control vertices of the patches
|
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
PatchParamTable _paramTable; // PatchParam bitfields (one per patch)
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
//
|
|
|
|
// Extraordinary vertex closed-form evaluation
|
|
|
|
//
|
|
|
|
|
|
|
|
// XXXX manuelk end-cap stencils will obsolete the other tables
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-04-08 01:34:05 +00:00
|
|
|
StencilTables const * _endcapVertexStencilTables;
|
|
|
|
StencilTables const * _endcapVaryingStencilTables;
|
2014-11-25 20:41:19 +00:00
|
|
|
QuadOffsetsTable _quadOffsetsTable; // Quad offsets (for Gregory patches)
|
2014-11-11 19:27:25 +00:00
|
|
|
VertexValenceTable _vertexValenceTable; // Vertex valence table (for Gregory patches)
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
//
|
|
|
|
// Face-varying data
|
|
|
|
//
|
2013-03-08 01:50:15 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
FVarPatchChannelVector _fvarChannels;
|
2014-10-13 15:52:09 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
//
|
|
|
|
// 'single-crease' patch sharpness tables
|
|
|
|
//
|
2014-10-13 15:52:09 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
std::vector<Index> _sharpnessIndices; // Indices of single-crease sharpness (one per patch)
|
|
|
|
std::vector<float> _sharpnessValues; // Sharpness values.
|
2012-12-11 01:15:13 +00:00
|
|
|
};
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
// XXXX manuelk evaluation should have the following interface :
|
|
|
|
// - EvaluateVertex<>()
|
|
|
|
// - EvaluateVarying<>()
|
|
|
|
// - EvaluateFaceVarying<>()
|
|
|
|
// this refactor is pending the move of fvar channels as a private data
|
|
|
|
// structure inside PatchTables, along with the addition of accessors that
|
|
|
|
// use PatchHandle and work that hides the indexing of the patches inside
|
|
|
|
// the tables
|
2014-11-12 01:35:52 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
// Interpolates primvar limit at the given parametric location on a patch
|
2014-10-02 23:09:17 +00:00
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2015-02-26 21:57:47 +00:00
|
|
|
PatchTables::Evaluate(PatchHandle const & handle, float s, float t,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) const {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-10-21 23:36:26 +00:00
|
|
|
assert(IsFeatureAdaptive());
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
PatchParam::BitField const & bits = _paramTable[handle.patchIndex].bitField;
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
PatchDescriptor::Type ptype =
|
|
|
|
GetPatchArrayDescriptor(handle.arrayIndex).GetType();
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
dst.Clear();
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
float Q[16], Qd1[16], Qd2[16];
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2015-04-17 23:26:57 +00:00
|
|
|
if (ptype==PatchDescriptor::REGULAR) {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2015-01-27 23:38:30 +00:00
|
|
|
GetBSplineWeights(bits, s, t, Q, Qd1, Qd2);
|
2014-09-22 17:34:46 +00:00
|
|
|
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstIndexArray cvs = GetPatchVertices(handle);
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2015-04-17 23:26:57 +00:00
|
|
|
InterpolateRegularPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
// XXXdyu bits InterpolateBoundaryPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
// XXXdyu bits InterpolateCornerPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
} else if (ptype==PatchDescriptor::GREGORY_BASIS) {
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2015-04-08 01:34:05 +00:00
|
|
|
assert(_endcapVertexStencilTables);
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2015-04-11 00:45:00 +00:00
|
|
|
ConstIndexArray cvs = GetPatchVertices(handle);
|
|
|
|
|
2015-01-27 23:38:30 +00:00
|
|
|
GetBezierWeights(bits, s, t, Q, Qd1, Qd2);
|
2015-04-11 00:45:00 +00:00
|
|
|
InterpolateGregoryPatch(cvs.begin(), s, t, Q, Qd1, Qd2, src, dst);
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
} else if (ptype==PatchDescriptor::QUADS) {
|
|
|
|
|
|
|
|
ConstIndexArray cvs = GetPatchVertices(handle);
|
|
|
|
|
|
|
|
GetBilinearWeights(bits, s, t, Q, Qd1, Qd2);
|
|
|
|
InterpolateBilinearPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
} else {
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-26 21:57:47 +00:00
|
|
|
// Interpolates the limit position of a parametric location on a face-varying
|
|
|
|
// patch
|
|
|
|
// XXXX manuelk this method is very similar to the vertex Evaluate<>() method
|
|
|
|
// -> we should eventually merge them
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
|
|
|
PatchTables::EvaluateFaceVarying(int channel, PatchHandle const & handle,
|
|
|
|
float s, float t, T const & src, U & dst) const {
|
|
|
|
|
|
|
|
ConstIndexArray cvs = GetFVarPatchValues(channel, handle);
|
|
|
|
|
|
|
|
PatchDescriptor::Type type = GetFVarPatchType(channel, handle);
|
|
|
|
|
|
|
|
PatchParam::BitField bits;
|
|
|
|
bits.Clear();
|
|
|
|
|
|
|
|
float Q[16], Qd1[16], Qd2[16];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case PatchDescriptor::QUADS:
|
|
|
|
GetBilinearWeights(bits, s, t, Q, Qd1, Qd2);
|
|
|
|
InterpolateBilinearPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
break;
|
|
|
|
case PatchDescriptor::TRIANGLES:
|
|
|
|
assert("not implemented yet");
|
|
|
|
case PatchDescriptor::REGULAR:
|
|
|
|
GetBSplineWeights(bits, s, t, Q, Qd1, Qd2);
|
|
|
|
InterpolateRegularPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
2015-04-17 14:42:53 +00:00
|
|
|
// XXXdyu bits InterpolateBoundaryPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
// XXXdyu bits InterpolateCornerPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
2015-02-26 21:57:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
|
|
|
|
// XXXX manuelk - how do we handle end-patches ?
|
|
|
|
// - is there a bicubic patch that we could use to reduce
|
|
|
|
// isolation of bilinear boundaries with smooth a interior ?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Interpolates primvar at the given parametric location on a bilinear patch
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
|
|
|
PatchTables::EvaluateBilinear(PatchHandle const & handle, float s, float t,
|
|
|
|
T const & src, U & dst) const {
|
|
|
|
|
|
|
|
ConstIndexArray cvs = GetPatchVertices(handle);
|
|
|
|
assert(cvs.size()==4);
|
|
|
|
|
|
|
|
PatchParam::BitField const & bits =
|
|
|
|
_paramTable[handle.patchIndex].bitField;
|
|
|
|
|
|
|
|
dst.Clear();
|
|
|
|
|
|
|
|
float Q[4], Qd1[4], Qd2[4];
|
|
|
|
GetBilinearWeights(bits, s, t, Q, Qd1, Qd2);
|
|
|
|
|
|
|
|
InterpolateBilinearPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
} // end namespace Far
|
2013-03-23 01:20:50 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2013-03-23 01:20:50 +00:00
|
|
|
#endif /* FAR_PATCH_TABLES */
|