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
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
#include "../far/patchDescriptor.h"
|
2014-10-09 21:48:50 +00:00
|
|
|
#include "../far/patchParam.h"
|
2014-11-11 19:27:25 +00:00
|
|
|
#include "../far/stencilTables.h"
|
2014-09-05 22:07:46 +00:00
|
|
|
#include "../far/types.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
|
|
|
///
|
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 {
|
|
|
|
// XXXX manuelk members will eventually be private once FVar
|
|
|
|
// interpolation is implemented fully
|
|
|
|
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 Direct accessors
|
|
|
|
///
|
|
|
|
/// \warning These direct accessors are left for convenience, but they are
|
|
|
|
/// likely going to be deprecated in future releases
|
|
|
|
///
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
typedef std::vector<Index> PatchVertsTable;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Get the table of patch control vertices
|
|
|
|
PatchVertsTable const & GetPatchControlVerticesTable() const { return _patchVerts; }
|
2013-05-17 16:06:40 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the PatchParamTable (PatchParams order matches patch array sorting)
|
|
|
|
PatchParamTable const & GetPatchParamTable() const { return _paramTable; }
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns a sharpness index table for each patch (if exists)
|
|
|
|
std::vector<Index> const &GetSharpnessIndexTable() const { return _sharpnessIndices; }
|
2013-05-17 16:06:40 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns sharpness values table
|
|
|
|
std::vector<float> const &GetSharpnessValues() const { return _sharpnessValues; }
|
2014-10-09 21:48:50 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
typedef std::vector<unsigned int> QuadOffsetsTable;
|
2014-02-25 01:12:39 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \brief Returns the quad-offsets table
|
|
|
|
QuadOffsetsTable const & GetQuadOffsetsTable() const {
|
|
|
|
return _quadOffsetsTable;
|
|
|
|
}
|
|
|
|
//@}
|
2013-05-10 17:44:03 +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
|
|
|
|
StencilTables const * GetEndCapStencilTables() const { return _endcapStencilTables; }
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
Index GetEndCapStencilIndex(PatchHandle const & handle) const {
|
|
|
|
return handle.vertIndex;
|
2014-11-12 01:35:52 +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;
|
|
|
|
//@}
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/// @name Face-varying
|
|
|
|
///
|
|
|
|
/// \anchor face_varying
|
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Face-varying patch vertex indices tables
|
|
|
|
///
|
|
|
|
/// FVarPatchTables contain the topology for face-varying primvar data
|
|
|
|
/// channels. The patch ordering matches that of PatchTables PatchArrays.
|
|
|
|
///
|
2014-11-25 20:41:19 +00:00
|
|
|
/// \note bi-cubic face-varying limit interpolation is not implemented yet :
|
|
|
|
/// this code will change soon
|
|
|
|
///
|
2014-09-05 22:07:46 +00:00
|
|
|
class FVarPatchTables {
|
2014-04-05 02:10:34 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Returns the number of face-varying primvar channels
|
|
|
|
int GetNumChannels() const {
|
|
|
|
return (int)_channels.size();
|
2014-04-05 02:10:34 +00:00
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
/// \brief Returns the face-varying patches vertex indices
|
|
|
|
///
|
|
|
|
/// @param channel Then face-varying primvar channel index
|
|
|
|
///
|
2014-10-09 21:48:50 +00:00
|
|
|
std::vector<Index> const & GetPatchVertices(int channel) const {
|
2014-09-05 22:07:46 +00:00
|
|
|
return _channels[channel].patchVertIndices;
|
2014-04-05 02:10:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-25 20:41:19 +00:00
|
|
|
friend class PatchTables;
|
2014-09-05 22:07:46 +00:00
|
|
|
friend class PatchTablesFactory;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
struct Channel {
|
|
|
|
friend class PatchTablesFactory;
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2014-10-09 21:48:50 +00:00
|
|
|
std::vector<Index> patchVertIndices; // face-varying vertex indices
|
2014-09-05 22:07:46 +00:00
|
|
|
};
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
private:
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
std::vector<Channel> _channels; // face-varying primvar channels
|
2014-04-05 02:10:34 +00:00
|
|
|
};
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
/// \brief Returns the face-varying patches
|
|
|
|
FVarPatchTables const * GetFVarPatchTables() const { return _fvarPatchTables; }
|
2014-11-25 20:41:19 +00:00
|
|
|
//@}
|
2014-04-05 02:10:34 +00:00
|
|
|
|
2014-10-02 23:09:17 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
//
|
|
|
|
// Interpolation methods
|
|
|
|
//
|
|
|
|
|
|
|
|
/// \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)
|
|
|
|
///
|
2014-10-02 23:09:17 +00:00
|
|
|
template <class T, class U> void Interpolate(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
|
|
|
/// \brief Interpolate the (s,t) parametric location of a bilinear (quad)
|
|
|
|
/// patch
|
|
|
|
///
|
|
|
|
template <class T, class U> static void
|
2014-10-09 21:48:50 +00:00
|
|
|
InterpolateBilinear(Index const * cvs, float s, float t,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst);
|
2014-10-02 23:09:17 +00:00
|
|
|
|
|
|
|
/// \brief Interpolate the (s,t) parametric location of a regular bicubic
|
|
|
|
/// patch
|
|
|
|
///
|
|
|
|
/// @param cvs Array of 16 control vertex indices
|
|
|
|
///
|
|
|
|
/// @param Q Array of 16 bicubic weights for the control vertices
|
|
|
|
///
|
|
|
|
/// @param Qd1 Array of 16 bicubic 's' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param Qd2 Array of 16 bicubic 't' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
|
|
|
template <class T, class U> static void
|
2014-10-09 21:48:50 +00:00
|
|
|
InterpolateRegularPatch(Index const * cvs,
|
2014-10-21 23:36:26 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2, T const & src, U & dst);
|
2014-10-02 23:09:17 +00:00
|
|
|
|
|
|
|
/// \brief Interpolate the (s,t) parametric location of a boundary bicubic
|
|
|
|
/// patch
|
|
|
|
///
|
|
|
|
/// @param cvs Array of 12 control vertex indices
|
|
|
|
///
|
|
|
|
/// @param Q Array of 12 bicubic weights for the control vertices
|
|
|
|
///
|
|
|
|
/// @param Qd1 Array of 12 bicubic 's' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param Qd2 Array of 12 bicubic 't' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
|
|
|
template <class T, class U> static void
|
2014-10-09 21:48:50 +00:00
|
|
|
InterpolateBoundaryPatch(Index const * cvs,
|
2014-10-21 23:36:26 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2, T const & src, U & dst);
|
2014-10-02 23:09:17 +00:00
|
|
|
|
|
|
|
/// \brief Interpolate the (s,t) parametric location of a corner bicubic
|
|
|
|
/// patch
|
|
|
|
///
|
|
|
|
/// @param cvs Array of 9 control vertex indices
|
|
|
|
///
|
|
|
|
/// @param Q Array of 9 bicubic weights for the control vertices
|
|
|
|
///
|
|
|
|
/// @param Qd1 Array of 9 bicubic 's' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param Qd2 Array of 9 bicubic 't' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
|
|
|
template <class T, class U> static void
|
2014-10-09 21:48:50 +00:00
|
|
|
InterpolateCornerPatch(Index const * cvs,
|
2014-10-21 23:36:26 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2, T const & src, U & dst);
|
2014-10-02 23:09:17 +00:00
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
/// \brief Interpolate the (s,t) parametric location of a Gregory bicubic
|
|
|
|
/// patch
|
|
|
|
///
|
|
|
|
/// @param basisStencils Stencil tables driving the 20 CV basis of the patches
|
|
|
|
///
|
|
|
|
/// @param stencilIndex Index of the first CV stencil in the basis stencils tables
|
|
|
|
///
|
2014-11-13 18:28:31 +00:00
|
|
|
/// @param s Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
|
|
|
/// @param t Patch coordinate (in coarse face normalized space)
|
|
|
|
///
|
2014-11-11 19:27:25 +00:00
|
|
|
/// @param Q Array of 9 bicubic weights for the control vertices
|
|
|
|
///
|
|
|
|
/// @param Qd1 Array of 9 bicubic 's' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param Qd2 Array of 9 bicubic 't' tangent weights for the control
|
|
|
|
/// vertices
|
|
|
|
///
|
|
|
|
/// @param src Source primvar buffer (control vertices data)
|
|
|
|
///
|
|
|
|
/// @param dst Destination primvar buffer (limit surface data)
|
|
|
|
///
|
|
|
|
template <class T, class U> static void
|
|
|
|
InterpolateGregoryPatch(StencilTables const * basisStencils, int stencilIndex,
|
|
|
|
float s, float t, float const * Q, float const *Qd1, float const *Qd2,
|
|
|
|
T const & src, U & dst);
|
|
|
|
|
2014-10-02 23:09:17 +00:00
|
|
|
/// \brief Interpolate the (s,t) parametric location of a *bicubic* patch
|
|
|
|
///
|
|
|
|
/// \note This method can only be used on feature adaptive PatchTables (ie.
|
|
|
|
/// IsFeatureAdaptive() is false)
|
|
|
|
///
|
|
|
|
/// @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)
|
|
|
|
///
|
|
|
|
template <class T, class U> void Limit(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-11-11 19:27:25 +00:00
|
|
|
enum TensorBasis {
|
2014-12-25 21:03:53 +00:00
|
|
|
BASIS_BEZIER, ///< Bi-cubic bezier patch basis
|
|
|
|
BASIS_BSPLINE ///< Bi-cubic bspline patch basis
|
2014-11-11 19:27:25 +00:00
|
|
|
};
|
|
|
|
|
2014-12-25 21:03:53 +00:00
|
|
|
/// \brief Returns bi-cubic weights matrix for a given (s,t) location
|
|
|
|
/// on the patch
|
|
|
|
static void GetBasisWeights(TensorBasis basis, PatchParam::BitField bits,
|
2014-11-11 19:27:25 +00:00
|
|
|
float s, float t, float point[16], float deriv1[16], float deriv2[16]);
|
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);
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
void reservePatchArrays(int numPatchArrays);
|
|
|
|
|
|
|
|
void pushPatchArray(PatchDescriptor desc,
|
|
|
|
int npatches, Index * vidx, Index * pidx, Index * qoidx=0);
|
|
|
|
|
|
|
|
Index findPatchArray(PatchDescriptor desc);
|
|
|
|
|
|
|
|
IndexArray getPatchArrayVertices(int arrayIndex);
|
|
|
|
PatchParamArray getPatchParams(int arrayIndex);
|
|
|
|
|
|
|
|
Index * getSharpnessIndices(Index arrayIndex);
|
|
|
|
float * getSharpnessValues(Index arrayIndex);
|
|
|
|
|
|
|
|
IndexArray getFVarVerts(int arrayIndex, int channel);
|
|
|
|
|
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;
|
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
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
typedef std::vector<PatchArray> PatchArrayVector;
|
|
|
|
|
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
|
|
|
|
2014-11-18 18:48:37 +00:00
|
|
|
StencilTables const * _endcapStencilTables;
|
|
|
|
#ifdef ENDCAP_TOPOPOLGY
|
2014-11-25 20:41:19 +00:00
|
|
|
std::vector<Index> _endcapTopology;
|
2014-11-18 18:48:37 +00:00
|
|
|
#endif
|
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
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
FVarPatchTables * _fvarPatchTables; // sparse face-varying patch table (one per patch)
|
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
|
|
|
};
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2014-10-09 21:48:50 +00:00
|
|
|
PatchTables::InterpolateBilinear(Index const * cvs, float s, float t,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) {
|
2014-10-02 23:09:17 +00:00
|
|
|
|
|
|
|
float os = 1.0f - s,
|
|
|
|
ot = 1.0f - t,
|
|
|
|
Q[4] = { os*ot, s*ot, s*t, os*t },
|
|
|
|
dQ1[4] = { t-1.0f, ot, t, -t },
|
|
|
|
dQ2[4] = { s-1.0f, -s, s, os };
|
|
|
|
|
|
|
|
for (int k=0; k<4; ++k) {
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k]], Q[k], dQ1[k], dQ2[k]);
|
2014-10-02 23:09:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2014-10-09 21:48:50 +00:00
|
|
|
PatchTables::InterpolateRegularPatch(Index const * cvs,
|
2014-09-19 00:48:34 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// v0 -- v1 -- v2 -- v3
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// v4 -- v5 -- v6 -- v7
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// v8 -- v9 -- v10-- v11
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// v12-- v13-- v14-- v15
|
|
|
|
//
|
|
|
|
for (int k=0; k<16; ++k) {
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k]], Q[k], Qd1[k], Qd2[k]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2014-10-09 21:48:50 +00:00
|
|
|
PatchTables::InterpolateBoundaryPatch(Index const * cvs,
|
2014-09-19 00:48:34 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
|
|
|
// mirror the missing vertices (M)
|
|
|
|
//
|
|
|
|
// M0 -- M1 -- M2 -- M3 (corner)
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
|
|
|
// v0 -- v1 -- v2 -- v3 M : mirrored
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// v4 -- v5 -- v6 -- v7 v : original Cv
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// |.....|.....|.....|
|
|
|
|
// v8 -- v9 -- v10-- v11
|
|
|
|
//
|
|
|
|
for (int k=0; k<4; ++k) { // M0 - M3
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k]], 2.0f*Q[k], 2.0f*Qd1[k], 2.0f*Qd2[k]);
|
|
|
|
dst.AddWithWeight(src[cvs[k+4]], -1.0f*Q[k], -1.0f*Qd1[k], -1.0f*Qd2[k]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
for (int k=0; k<12; ++k) {
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k]], Q[k+4], Qd1[k+4], Qd2[k+4]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2014-10-09 21:48:50 +00:00
|
|
|
PatchTables::InterpolateCornerPatch(Index const * cvs,
|
2014-09-19 00:48:34 +00:00
|
|
|
float const * Q, float const *Qd1, float const *Qd2,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
|
|
|
// mirror the missing vertices (M)
|
|
|
|
//
|
|
|
|
// M0 -- M1 -- M2 -- M3 (corner)
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
|
|
|
// v0 -- v1 -- v2 -- M4 M : mirrored
|
|
|
|
// |.....|.....| |
|
|
|
|
// |.....|.....| |
|
|
|
|
// v3.--.v4.--.v5 -- M5 v : original Cv
|
|
|
|
// |.....|.....| |
|
|
|
|
// |.....|.....| |
|
|
|
|
// v6 -- v7 -- v8 -- M6
|
|
|
|
//
|
|
|
|
for (int k=0; k<3; ++k) { // M0 - M2
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k ]], 2.0f*Q[k], 2.0f*Qd1[k], 2.0f*Qd2[k]);
|
|
|
|
dst.AddWithWeight(src[cvs[k+3]], -1.0f*Q[k], -1.0f*Qd1[k], -1.0f*Qd2[k]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
for (int k=0; k<3; ++k) { // M4 - M6
|
|
|
|
int idx = (k+1)*4 + 3;
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[k*3+2]], 2.0f*Q[idx], 2.0f*Qd1[idx], 2.0f*Qd2[idx]);
|
|
|
|
dst.AddWithWeight(src[cvs[k*3+1]], -1.0f*Q[idx], -1.0f*Qd1[idx], -1.0f*Qd2[idx]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
// M3 = -2.v1 + 4.v2 + v4 - 2.v5
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[1]], -2.0f*Q[3], -2.0f*Qd1[3], -2.0f*Qd2[3]);
|
|
|
|
dst.AddWithWeight(src[cvs[2]], 4.0f*Q[3], 4.0f*Qd1[3], 4.0f*Qd2[3]);
|
|
|
|
dst.AddWithWeight(src[cvs[4]], 1.0f*Q[3], 1.0f*Qd1[3], 1.0f*Qd2[3]);
|
|
|
|
dst.AddWithWeight(src[cvs[5]], -2.0f*Q[3], -2.0f*Qd1[3], -2.0f*Qd2[3]);
|
2014-09-19 00:48:34 +00:00
|
|
|
for (int y=0; y<3; ++y) { // v0 - v8
|
|
|
|
for (int x=0; x<3; ++x) {
|
|
|
|
int idx = y*4+x+4;
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.AddWithWeight(src[cvs[y*3+x]], Q[idx], Qd1[idx], Qd2[idx]);
|
2014-09-19 00:48:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-11 19:27:25 +00:00
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
|
|
|
PatchTables::InterpolateGregoryPatch(StencilTables const * basisStencils,
|
|
|
|
int stencilIndex, float s, float t,
|
|
|
|
float const * Q, float const *Qd1, float const *Qd2,
|
|
|
|
T const & src, U & dst) {
|
|
|
|
|
2014-11-12 01:35:52 +00:00
|
|
|
float ss = 1-s,
|
|
|
|
tt = 1-t;
|
2014-11-11 19:27:25 +00:00
|
|
|
// remark #1572: floating-point equality and inequality comparisons are unreliable
|
|
|
|
#ifdef __INTEL_COMPILER
|
|
|
|
#pragma warning disable 1572
|
|
|
|
#endif
|
2014-11-12 01:35:52 +00:00
|
|
|
float d11 = s+t; if(s+t==0.0f) d11 = 1.0f;
|
|
|
|
float d12 = ss+t; if(ss+t==0.0f) d12 = 1.0f;
|
|
|
|
float d21 = s+tt; if(s+tt==0.0f) d21 = 1.0f;
|
|
|
|
float d22 = ss+tt; if(ss+tt==0.0f) d22 = 1.0f;
|
2014-11-11 19:27:25 +00:00
|
|
|
#ifdef __INTEL_COMPILER
|
|
|
|
#pragma warning enable 1572
|
|
|
|
#endif
|
|
|
|
|
2014-11-12 01:35:52 +00:00
|
|
|
float weights[4][2] = { { s/d11, t/d11 },
|
|
|
|
{ ss/d12, t/d12 },
|
|
|
|
{ s/d21, tt/d21 },
|
|
|
|
{ ss/d22, tt/d22 } };
|
|
|
|
|
|
|
|
//
|
|
|
|
// P3 e3- e2+ P2
|
|
|
|
// O--------O--------O--------O
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
|
|
|
// | | f3- | f2+ |
|
|
|
|
// | O O |
|
|
|
|
// e3+ O------O O------O e2-
|
|
|
|
// | f3+ f2- |
|
|
|
|
// | |
|
|
|
|
// | |
|
|
|
|
// | f0- f1+ |
|
|
|
|
// e0- O------O O------O e1+
|
|
|
|
// | O O |
|
|
|
|
// | | f0+ | f1- |
|
|
|
|
// | | | |
|
|
|
|
// | | | |
|
|
|
|
// O--------O--------O--------O
|
|
|
|
// P0 e0+ e1- P1
|
|
|
|
//
|
|
|
|
// XXXX manuelk re-order stencils in factory and get rid of permutation ?
|
|
|
|
int const permute[16] =
|
|
|
|
{ 0, 1, 7, 5, 2, -1, -1, 6, 16, -1, -1, 12, 15, 17, 11, 10 };
|
|
|
|
|
|
|
|
for (int i=0, fcount=0; i<16; ++i) {
|
|
|
|
|
|
|
|
int index = permute[i],
|
|
|
|
offset = stencilIndex;
|
|
|
|
|
|
|
|
if (index==-1) {
|
|
|
|
|
|
|
|
// 0-ring vertex: blend 2 extra basis CVs
|
|
|
|
int const fpermute[4][2] = { {3, 4}, {9, 8}, {19, 18}, {13, 14} };
|
|
|
|
|
|
|
|
assert(fcount < 4);
|
|
|
|
int v0 = fpermute[fcount][0],
|
|
|
|
v1 = fpermute[fcount][1];
|
|
|
|
|
|
|
|
Stencil s0 = basisStencils->GetStencil(offset + v0),
|
|
|
|
s1 = basisStencils->GetStencil(offset + v1);
|
|
|
|
|
|
|
|
float w0=weights[fcount][0],
|
|
|
|
w1=weights[fcount][1];
|
|
|
|
|
|
|
|
{
|
|
|
|
Index const * srcIndices = s0.GetVertexIndices();
|
|
|
|
float const * srcWeights = s0.GetWeights();
|
|
|
|
for (int j=0; j<s0.GetSize(); ++j) {
|
|
|
|
dst.AddWithWeight(src[srcIndices[j]],
|
|
|
|
Q[i]*w0*srcWeights[j], Qd1[i]*w0*srcWeights[j],
|
|
|
|
Qd2[i]*w0*srcWeights[j]);
|
2014-11-11 19:27:25 +00:00
|
|
|
}
|
2014-11-12 01:35:52 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
Index const * srcIndices = s1.GetVertexIndices();
|
|
|
|
float const * srcWeights = s1.GetWeights();
|
|
|
|
for (int j=0; j<s1.GetSize(); ++j) {
|
|
|
|
dst.AddWithWeight(src[srcIndices[j]],
|
|
|
|
Q[i]*w1*srcWeights[j], Qd1[i]*w1*srcWeights[j],
|
|
|
|
Qd2[i]*w1*srcWeights[j]);
|
2014-11-11 19:27:25 +00:00
|
|
|
}
|
|
|
|
}
|
2014-11-12 01:35:52 +00:00
|
|
|
++fcount;
|
|
|
|
} else {
|
|
|
|
Stencil s = basisStencils->GetStencil(offset + index);
|
|
|
|
Index const * srcIndices = s.GetVertexIndices();
|
|
|
|
float const * srcWeights = s.GetWeights();
|
|
|
|
for (int j=0; j<s.GetSize(); ++j) {
|
|
|
|
dst.AddWithWeight( src[srcIndices[j]],
|
|
|
|
Q[i]*srcWeights[j], Qd1[i]*srcWeights[j],
|
|
|
|
Qd2[i]*srcWeights[j]);
|
|
|
|
}
|
2014-11-11 19:27:25 +00:00
|
|
|
}
|
2014-11-12 01:35:52 +00:00
|
|
|
}
|
2014-11-11 19:27:25 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 19:10:13 +00:00
|
|
|
// Interpolates the limit position of a parametric location on a bilinear patch
|
2014-10-02 23:09:17 +00:00
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
|
|
|
PatchTables::Interpolate(PatchHandle const & handle, float s, float t,
|
2014-10-21 23:36:26 +00:00
|
|
|
T const & src, U & dst) const {
|
2014-10-02 23:09:17 +00:00
|
|
|
|
2014-10-21 23:36:26 +00:00
|
|
|
assert(not IsFeatureAdaptive());
|
2014-10-02 23:09:17 +00:00
|
|
|
|
2014-12-15 18:23:13 +00:00
|
|
|
ConstIndexArray cvs = GetPatchVertices(handle);
|
2014-10-02 23:09:17 +00:00
|
|
|
|
|
|
|
PatchParam::BitField const & bits =
|
2014-11-25 20:41:19 +00:00
|
|
|
_paramTable[handle.patchIndex].bitField;
|
2014-10-02 23:09:17 +00:00
|
|
|
bits.Normalize(s,t);
|
|
|
|
|
|
|
|
|
2014-10-21 23:36:26 +00:00
|
|
|
dst.Clear();
|
2014-10-02 23:09:17 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
InterpolateBilinear(cvs.begin(), s, t, src, dst);
|
2014-10-02 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 00:48:34 +00:00
|
|
|
// Interpolates the limit position of a parametric location on a patch
|
|
|
|
template <class T, class U>
|
|
|
|
inline void
|
2014-09-20 00:22:35 +00:00
|
|
|
PatchTables::Limit(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
|
|
|
bits.Normalize(s,t);
|
|
|
|
|
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
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
if (ptype>=PatchDescriptor::REGULAR and ptype<=PatchDescriptor::CORNER) {
|
2014-09-19 00:48:34 +00:00
|
|
|
|
2014-12-25 21:03:53 +00:00
|
|
|
GetBasisWeights(BASIS_BSPLINE, 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
|
|
|
|
|
|
|
switch (ptype) {
|
2014-11-25 20:41:19 +00:00
|
|
|
case PatchDescriptor::REGULAR:
|
|
|
|
InterpolateRegularPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
2014-09-19 00:48:34 +00:00
|
|
|
break;
|
2014-11-25 20:41:19 +00:00
|
|
|
case PatchDescriptor::SINGLE_CREASE:
|
2014-10-13 15:52:09 +00:00
|
|
|
// TODO: implement InterpolateSingleCreasePatch().
|
|
|
|
//InterpolateRegularPatch(cvs, Q, Qd1, Qd2, src, dst);
|
|
|
|
break;
|
2014-11-25 20:41:19 +00:00
|
|
|
case PatchDescriptor::BOUNDARY:
|
|
|
|
InterpolateBoundaryPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
2014-09-19 00:48:34 +00:00
|
|
|
break;
|
2014-11-25 20:41:19 +00:00
|
|
|
case PatchDescriptor::CORNER:
|
|
|
|
InterpolateCornerPatch(cvs.begin(), Q, Qd1, Qd2, src, dst);
|
2014-09-19 00:48:34 +00:00
|
|
|
break;
|
2014-11-25 20:41:19 +00:00
|
|
|
case PatchDescriptor::GREGORY:
|
|
|
|
case PatchDescriptor::GREGORY_BOUNDARY:
|
2014-11-11 19:27:25 +00:00
|
|
|
assert(0);
|
|
|
|
break;
|
2014-09-19 00:48:34 +00:00
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
2014-11-25 20:41:19 +00:00
|
|
|
} else if (ptype==PatchDescriptor::GREGORY_BASIS) {
|
2014-11-11 19:27:25 +00:00
|
|
|
|
|
|
|
assert(_endcapStencilTables);
|
|
|
|
|
2014-12-25 21:03:53 +00:00
|
|
|
GetBasisWeights(BASIS_BEZIER, bits, s, t, Q, Qd1, Qd2);
|
2014-11-11 19:27:25 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
InterpolateGregoryPatch(_endcapStencilTables, handle.vertIndex,
|
2014-11-11 19:27:25 +00:00
|
|
|
s, t, Q, Qd1, Qd2, src, dst);
|
2014-09-19 00:48:34 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 */
|