2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-03-08 01:50:15 +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:
|
2013-03-08 01:50:15 +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.
|
2013-03-08 01:50:15 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-03-08 01:50:15 +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.
|
2013-03-08 01:50:15 +00:00
|
|
|
//
|
|
|
|
|
2014-03-25 02:13:40 +00:00
|
|
|
#ifndef OSDUTIL_MULTI_MESH_FACTORY_H
|
|
|
|
#define OSDUTIL_MULTI_MESH_FACTORY_H
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
|
|
|
#include "../far/mesh.h"
|
2014-03-20 21:52:42 +00:00
|
|
|
|
|
|
|
#include "../far/meshFactory.h"
|
2013-03-08 01:50:15 +00:00
|
|
|
#include "../far/patchTablesFactory.h"
|
|
|
|
#include "../far/vertexEditTablesFactory.h"
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2013-05-07 02:05:50 +00:00
|
|
|
/// \brief A specialized factory for batching meshes
|
|
|
|
///
|
|
|
|
/// Because meshes require multiple draw calls in order to process the different
|
|
|
|
/// types of patches, it is useful to have the ability of grouping the tables of
|
|
|
|
/// multiple meshes into a single set of tables. This factory builds upon the
|
|
|
|
/// specialized Far factories in order to provide this batching functionality.
|
|
|
|
///
|
2014-03-25 02:13:40 +00:00
|
|
|
template <class T, class U=T> class OsdUtilMultiMeshFactory {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
public:
|
2013-05-07 02:05:50 +00:00
|
|
|
|
|
|
|
typedef std::vector<FarMesh<U> const *> FarMeshVector;
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Constructor.
|
2014-03-25 02:13:40 +00:00
|
|
|
OsdUtilMultiMeshFactory();
|
|
|
|
|
2013-07-11 01:51:43 +00:00
|
|
|
/// \brief Splices a vector of Far meshes into a single Far mesh
|
2013-05-07 02:05:50 +00:00
|
|
|
///
|
|
|
|
/// @param meshes a vector of Far meshes to splice
|
|
|
|
///
|
|
|
|
/// @return the resulting spliced Far mesh
|
|
|
|
///
|
2013-03-08 01:50:15 +00:00
|
|
|
FarMesh<U> * Create(std::vector<FarMesh<U> const *> const &meshes);
|
|
|
|
|
2013-05-10 02:16:51 +00:00
|
|
|
std::vector<FarPatchTables::PatchArrayVector> const & GetMultiPatchArrays() {
|
2014-03-25 02:13:40 +00:00
|
|
|
return _multiPatchArrays;
|
2013-05-10 02:16:51 +00:00
|
|
|
}
|
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
private:
|
2013-05-10 02:16:51 +00:00
|
|
|
// patch arrays for each mesh
|
|
|
|
std::vector<FarPatchTables::PatchArrayVector> _multiPatchArrays;
|
2013-03-08 01:50:15 +00:00
|
|
|
};
|
|
|
|
|
2014-03-20 00:19:08 +00:00
|
|
|
template <class T, class U>
|
2014-03-25 02:13:40 +00:00
|
|
|
OsdUtilMultiMeshFactory<T, U>::OsdUtilMultiMeshFactory() {
|
2014-03-20 00:19:08 +00:00
|
|
|
}
|
2013-05-07 02:05:50 +00:00
|
|
|
|
2013-03-08 01:50:15 +00:00
|
|
|
template <class T, class U> FarMesh<U> *
|
2014-03-25 02:13:40 +00:00
|
|
|
OsdUtilMultiMeshFactory<T, U>::Create(std::vector<FarMesh<U> const *> const &meshes) {
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
// splice subdivision tables
|
2014-03-25 02:13:40 +00:00
|
|
|
FarKernelBatchVector batches;
|
|
|
|
FarSubdivisionTables *subdivisionTables = FarSubdivisionTablesFactory<T, U>::Splice(meshes, &batches);
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
// splice patch/quad index tables
|
2014-03-25 02:13:40 +00:00
|
|
|
FarPatchTables *patchTables = FarPatchTablesFactory<T>::Splice(meshes,
|
|
|
|
&_multiPatchArrays);
|
2013-03-08 01:50:15 +00:00
|
|
|
|
|
|
|
// splice vertex edit tables
|
2014-03-25 02:13:40 +00:00
|
|
|
FarVertexEditTables *vertexEditTables = FarVertexEditTablesFactory<T, U>::Splice(meshes);
|
2013-03-08 01:50:15 +00:00
|
|
|
|
2014-03-25 02:13:40 +00:00
|
|
|
return new FarMesh<U>(subdivisionTables, patchTables, vertexEditTables, batches);
|
2013-03-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
|
|
|
} // end namespace OpenSubdiv
|
|
|
|
|
2014-03-25 02:13:40 +00:00
|
|
|
#endif /* OSDUTIL_MULTI_MESH_FACTORY_H */
|